+ Reply to Thread
Results 1 to 6 of 6

No Success with GetSaveAs

  1. #1
    D.Parker
    Guest

    No Success with GetSaveAs

    How do I get my new workbook filename to save to a given directory? The save
    as dialog box pops up with the NewName but unfortunately the file is "not"
    saved to the given directory when I click Save.

    I have a button on my spreadsheet when initiates the RenameFilenameUponClose
    subroutine. Dave kindly gave me advice, upon which I have tried them all but
    I still am not getting a new file save to my selected directory.

    Is there something obvious I am doing wrong or anything for that matter?
    The code is attached.

    Sub RenameFilenameUponClose()

    Dim SaveName As Variant
    Dim fFilter As String
    Dim NewName As String

    NewName = "P2 LogHistory Shift"
    fFilter = "Excel Files (*.xls), *.xls"
    SaveName = Application.GetSaveAsFilename _
    (NewName, FileFilter:=fFilter, Title:="Save As New P2 Workbook")

    If SaveName = True Then
    ThisWorkbook.SaveAs Filename:=SaveName, _
    FileFormat:=xlWorkbookNormal
    Else
    Exit Sub
    End If

    End Sub

    Kind regards,

    D.Parker

  2. #2
    Rowan
    Guest

    RE: No Success with GetSaveAs

    Your macro will never hit the ThisWorkbook.SaveAs statement as SaveName does
    not ever evaluate to True. It is either the path and name selected in the
    dialog or if the user hits cancel then it is False. Try

    Sub RenameFilenameUponClose()

    Dim SaveName As Variant
    Dim fFilter As String
    Dim NewName As String

    NewName = "P2 LogHistory Shift"
    fFilter = "Excel Files (*.xls), *.xls"
    SaveName = Application.GetSaveAsFilename _
    (NewName, FileFilter:=fFilter, Title:="Save As New P2 Workbook")

    If SaveName = False Then
    Exit Sub
    Else
    ThisWorkbook.SaveAs Filename:=SaveName, _
    FileFormat:=xlWorkbookNormal
    End If

    End Sub

    Hope this helps
    Rowan
    "D.Parker" wrote:

    > How do I get my new workbook filename to save to a given directory? The save
    > as dialog box pops up with the NewName but unfortunately the file is "not"
    > saved to the given directory when I click Save.
    >
    > I have a button on my spreadsheet when initiates the RenameFilenameUponClose
    > subroutine. Dave kindly gave me advice, upon which I have tried them all but
    > I still am not getting a new file save to my selected directory.
    >
    > Is there something obvious I am doing wrong or anything for that matter?
    > The code is attached.
    >
    > Sub RenameFilenameUponClose()
    >
    > Dim SaveName As Variant
    > Dim fFilter As String
    > Dim NewName As String
    >
    > NewName = "P2 LogHistory Shift"
    > fFilter = "Excel Files (*.xls), *.xls"
    > SaveName = Application.GetSaveAsFilename _
    > (NewName, FileFilter:=fFilter, Title:="Save As New P2 Workbook")
    >
    > If SaveName = True Then
    > ThisWorkbook.SaveAs Filename:=SaveName, _
    > FileFormat:=xlWorkbookNormal
    > Else
    > Exit Sub
    > End If
    >
    > End Sub
    >
    > Kind regards,
    >
    > D.Parker


  3. #3
    D.Parker
    Guest

    RE: No Success with GetSaveAs

    Wow. Thank you so much. It works!

    Thank you for loaning your expertise. You guys/gals are awesome.

    D.Parker

    "Rowan" wrote:

    > Your macro will never hit the ThisWorkbook.SaveAs statement as SaveName does
    > not ever evaluate to True. It is either the path and name selected in the
    > dialog or if the user hits cancel then it is False. Try
    >
    > Sub RenameFilenameUponClose()
    >
    > Dim SaveName As Variant
    > Dim fFilter As String
    > Dim NewName As String
    >
    > NewName = "P2 LogHistory Shift"
    > fFilter = "Excel Files (*.xls), *.xls"
    > SaveName = Application.GetSaveAsFilename _
    > (NewName, FileFilter:=fFilter, Title:="Save As New P2 Workbook")
    >
    > If SaveName = False Then
    > Exit Sub
    > Else
    > ThisWorkbook.SaveAs Filename:=SaveName, _
    > FileFormat:=xlWorkbookNormal
    > End If
    >
    > End Sub
    >
    > Hope this helps
    > Rowan
    > "D.Parker" wrote:
    >
    > > How do I get my new workbook filename to save to a given directory? The save
    > > as dialog box pops up with the NewName but unfortunately the file is "not"
    > > saved to the given directory when I click Save.
    > >
    > > I have a button on my spreadsheet when initiates the RenameFilenameUponClose
    > > subroutine. Dave kindly gave me advice, upon which I have tried them all but
    > > I still am not getting a new file save to my selected directory.
    > >
    > > Is there something obvious I am doing wrong or anything for that matter?
    > > The code is attached.
    > >
    > > Sub RenameFilenameUponClose()
    > >
    > > Dim SaveName As Variant
    > > Dim fFilter As String
    > > Dim NewName As String
    > >
    > > NewName = "P2 LogHistory Shift"
    > > fFilter = "Excel Files (*.xls), *.xls"
    > > SaveName = Application.GetSaveAsFilename _
    > > (NewName, FileFilter:=fFilter, Title:="Save As New P2 Workbook")
    > >
    > > If SaveName = True Then
    > > ThisWorkbook.SaveAs Filename:=SaveName, _
    > > FileFormat:=xlWorkbookNormal
    > > Else
    > > Exit Sub
    > > End If
    > >
    > > End Sub
    > >
    > > Kind regards,
    > >
    > > D.Parker


  4. #4
    Dave Peterson
    Guest

    Re: No Success with GetSaveAs

    Just curious--what was the difference between Rowan's suggestion and this:
    http://groups.google.co.uk/groups?th...0microsoft.com
    (one line in your browser)



    D.Parker wrote:
    >
    > Wow. Thank you so much. It works!
    >
    > Thank you for loaning your expertise. You guys/gals are awesome.
    >
    > D.Parker
    >
    > "Rowan" wrote:
    >
    > > Your macro will never hit the ThisWorkbook.SaveAs statement as SaveName does
    > > not ever evaluate to True. It is either the path and name selected in the
    > > dialog or if the user hits cancel then it is False. Try
    > >
    > > Sub RenameFilenameUponClose()
    > >
    > > Dim SaveName As Variant
    > > Dim fFilter As String
    > > Dim NewName As String
    > >
    > > NewName = "P2 LogHistory Shift"
    > > fFilter = "Excel Files (*.xls), *.xls"
    > > SaveName = Application.GetSaveAsFilename _
    > > (NewName, FileFilter:=fFilter, Title:="Save As New P2 Workbook")
    > >
    > > If SaveName = False Then
    > > Exit Sub
    > > Else
    > > ThisWorkbook.SaveAs Filename:=SaveName, _
    > > FileFormat:=xlWorkbookNormal
    > > End If
    > >
    > > End Sub
    > >
    > > Hope this helps
    > > Rowan
    > > "D.Parker" wrote:
    > >
    > > > How do I get my new workbook filename to save to a given directory? The save
    > > > as dialog box pops up with the NewName but unfortunately the file is "not"
    > > > saved to the given directory when I click Save.
    > > >
    > > > I have a button on my spreadsheet when initiates the RenameFilenameUponClose
    > > > subroutine. Dave kindly gave me advice, upon which I have tried them all but
    > > > I still am not getting a new file save to my selected directory.
    > > >
    > > > Is there something obvious I am doing wrong or anything for that matter?
    > > > The code is attached.
    > > >
    > > > Sub RenameFilenameUponClose()
    > > >
    > > > Dim SaveName As Variant
    > > > Dim fFilter As String
    > > > Dim NewName As String
    > > >
    > > > NewName = "P2 LogHistory Shift"
    > > > fFilter = "Excel Files (*.xls), *.xls"
    > > > SaveName = Application.GetSaveAsFilename _
    > > > (NewName, FileFilter:=fFilter, Title:="Save As New P2 Workbook")
    > > >
    > > > If SaveName = True Then
    > > > ThisWorkbook.SaveAs Filename:=SaveName, _
    > > > FileFormat:=xlWorkbookNormal
    > > > Else
    > > > Exit Sub
    > > > End If
    > > >
    > > > End Sub
    > > >
    > > > Kind regards,
    > > >
    > > > D.Parker


    --

    Dave Peterson

  5. #5
    Rowan
    Guest

    Re: No Success with GetSaveAs

    Looks about the same to me

    "Dave Peterson" wrote:

    > Just curious--what was the difference between Rowan's suggestion and this:
    > http://groups.google.co.uk/groups?th...0microsoft.com
    > (one line in your browser)
    >
    >
    >
    > D.Parker wrote:
    > >
    > > Wow. Thank you so much. It works!
    > >
    > > Thank you for loaning your expertise. You guys/gals are awesome.
    > >
    > > D.Parker
    > >
    > > "Rowan" wrote:
    > >
    > > > Your macro will never hit the ThisWorkbook.SaveAs statement as SaveName does
    > > > not ever evaluate to True. It is either the path and name selected in the
    > > > dialog or if the user hits cancel then it is False. Try
    > > >
    > > > Sub RenameFilenameUponClose()
    > > >
    > > > Dim SaveName As Variant
    > > > Dim fFilter As String
    > > > Dim NewName As String
    > > >
    > > > NewName = "P2 LogHistory Shift"
    > > > fFilter = "Excel Files (*.xls), *.xls"
    > > > SaveName = Application.GetSaveAsFilename _
    > > > (NewName, FileFilter:=fFilter, Title:="Save As New P2 Workbook")
    > > >
    > > > If SaveName = False Then
    > > > Exit Sub
    > > > Else
    > > > ThisWorkbook.SaveAs Filename:=SaveName, _
    > > > FileFormat:=xlWorkbookNormal
    > > > End If
    > > >
    > > > End Sub
    > > >
    > > > Hope this helps
    > > > Rowan
    > > > "D.Parker" wrote:
    > > >
    > > > > How do I get my new workbook filename to save to a given directory? The save
    > > > > as dialog box pops up with the NewName but unfortunately the file is "not"
    > > > > saved to the given directory when I click Save.
    > > > >
    > > > > I have a button on my spreadsheet when initiates the RenameFilenameUponClose
    > > > > subroutine. Dave kindly gave me advice, upon which I have tried them all but
    > > > > I still am not getting a new file save to my selected directory.
    > > > >
    > > > > Is there something obvious I am doing wrong or anything for that matter?
    > > > > The code is attached.
    > > > >
    > > > > Sub RenameFilenameUponClose()
    > > > >
    > > > > Dim SaveName As Variant
    > > > > Dim fFilter As String
    > > > > Dim NewName As String
    > > > >
    > > > > NewName = "P2 LogHistory Shift"
    > > > > fFilter = "Excel Files (*.xls), *.xls"
    > > > > SaveName = Application.GetSaveAsFilename _
    > > > > (NewName, FileFilter:=fFilter, Title:="Save As New P2 Workbook")
    > > > >
    > > > > If SaveName = True Then
    > > > > ThisWorkbook.SaveAs Filename:=SaveName, _
    > > > > FileFormat:=xlWorkbookNormal
    > > > > Else
    > > > > Exit Sub
    > > > > End If
    > > > >
    > > > > End Sub
    > > > >
    > > > > Kind regards,
    > > > >
    > > > > D.Parker

    >
    > --
    >
    > Dave Peterson
    >


  6. #6
    Dave Peterson
    Guest

    Re: No Success with GetSaveAs

    Then why didn't my suggestion work <vbg>?

    Rowan wrote:
    >
    > Looks about the same to me
    >
    > "Dave Peterson" wrote:
    >
    > > Just curious--what was the difference between Rowan's suggestion and this:
    > > http://groups.google.co.uk/groups?th...0microsoft.com
    > > (one line in your browser)
    > >
    > >
    > >
    > > D.Parker wrote:
    > > >
    > > > Wow. Thank you so much. It works!
    > > >
    > > > Thank you for loaning your expertise. You guys/gals are awesome.
    > > >
    > > > D.Parker
    > > >
    > > > "Rowan" wrote:
    > > >
    > > > > Your macro will never hit the ThisWorkbook.SaveAs statement as SaveName does
    > > > > not ever evaluate to True. It is either the path and name selected in the
    > > > > dialog or if the user hits cancel then it is False. Try
    > > > >
    > > > > Sub RenameFilenameUponClose()
    > > > >
    > > > > Dim SaveName As Variant
    > > > > Dim fFilter As String
    > > > > Dim NewName As String
    > > > >
    > > > > NewName = "P2 LogHistory Shift"
    > > > > fFilter = "Excel Files (*.xls), *.xls"
    > > > > SaveName = Application.GetSaveAsFilename _
    > > > > (NewName, FileFilter:=fFilter, Title:="Save As New P2 Workbook")
    > > > >
    > > > > If SaveName = False Then
    > > > > Exit Sub
    > > > > Else
    > > > > ThisWorkbook.SaveAs Filename:=SaveName, _
    > > > > FileFormat:=xlWorkbookNormal
    > > > > End If
    > > > >
    > > > > End Sub
    > > > >
    > > > > Hope this helps
    > > > > Rowan
    > > > > "D.Parker" wrote:
    > > > >
    > > > > > How do I get my new workbook filename to save to a given directory? The save
    > > > > > as dialog box pops up with the NewName but unfortunately the file is "not"
    > > > > > saved to the given directory when I click Save.
    > > > > >
    > > > > > I have a button on my spreadsheet when initiates the RenameFilenameUponClose
    > > > > > subroutine. Dave kindly gave me advice, upon which I have tried them all but
    > > > > > I still am not getting a new file save to my selected directory.
    > > > > >
    > > > > > Is there something obvious I am doing wrong or anything for that matter?
    > > > > > The code is attached.
    > > > > >
    > > > > > Sub RenameFilenameUponClose()
    > > > > >
    > > > > > Dim SaveName As Variant
    > > > > > Dim fFilter As String
    > > > > > Dim NewName As String
    > > > > >
    > > > > > NewName = "P2 LogHistory Shift"
    > > > > > fFilter = "Excel Files (*.xls), *.xls"
    > > > > > SaveName = Application.GetSaveAsFilename _
    > > > > > (NewName, FileFilter:=fFilter, Title:="Save As New P2 Workbook")
    > > > > >
    > > > > > If SaveName = True Then
    > > > > > ThisWorkbook.SaveAs Filename:=SaveName, _
    > > > > > FileFormat:=xlWorkbookNormal
    > > > > > Else
    > > > > > Exit Sub
    > > > > > End If
    > > > > >
    > > > > > End Sub
    > > > > >
    > > > > > Kind regards,
    > > > > >
    > > > > > D.Parker

    > >
    > > --
    > >
    > > Dave Peterson
    > >


    --

    Dave Peterson

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1