+ Reply to Thread
Results 1 to 16 of 16

No file when Save As is executed

Hybrid View

Guest No file when Save As is... 03-29-2005, 08:06 PM
Guest Re: No file when Save As is... 03-29-2005, 08:06 PM
Guest Re: No file when Save As is... 03-29-2005, 09:06 PM
Guest Re: No file when Save As is... 03-29-2005, 09:06 PM
Guest Re: No file when Save As is... 03-30-2005, 12:06 AM
Guest Re: No file when Save As is... 03-30-2005, 08:06 PM
Guest Re: No file when Save As is... 03-30-2005, 03:06 AM
Guest Re: No file when Save As is... 03-30-2005, 10:06 AM
Guest Re: No file when Save As is... 03-30-2005, 02:06 PM
  1. #1
    D.Parker
    Guest

    No file when Save As is executed

    I am trying to save a worksheet as a separate workbook. I am manipulating
    code from a pervious response. The Save As form comes up and I can set a
    file name and choose a path, but when I click the save button there is no
    file in my designated folder. The Save As is good since the user will be
    changing the filename each time upon exiting. I'm assuming I missing some
    code somewhere? Secondly, is there a way to save the worksheet object as
    opposed to the entire workbook (i.e. save the worksheet into a new workbook,
    less the VBA code preferrably)?

    Sub RenameFilenameUponClose()

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

    NewName = "P2 LogHistory Shift"
    fFilter = "Excel Files (*.xls), *.xls"
    SaveName = Application.GetSaveAsFilename _
    (NewName, fileFilter:=fFilter)

    End Sub

    Your help is greatly appreciated as always.

  2. #2
    Dave Peterson
    Guest

    Re: No file when Save As is executed

    This line:

    SaveName = Application.GetSaveAsFilename _
    (NewName, fileFilter:=fFilter)

    only returns the name of the file the user chose--it doesn't do the actual save.

    Sub RenameFilenameUponClose()

    Dim SaveName As variant '<--changed
    Dim fFilter As String
    Dim NewName As String

    NewName = "P2 LogHistory Shift"
    fFilter = "Excel Files (*.xls), *.xls"
    SaveName = Application.GetSaveAsFilename _
    (NewName, fileFilter:=fFilter)

    if savename = false then
    'use cancelled--what to do?
    else
    thisworkbook.saveas filename:=savename, fileformat:=xlworkbooknormal
    end if

    End Sub

    I change SaveName from a String to Variant--so that it could represent the
    boolean value False, too.

    D.Parker wrote:
    >
    > I am trying to save a worksheet as a separate workbook. I am manipulating
    > code from a pervious response. The Save As form comes up and I can set a
    > file name and choose a path, but when I click the save button there is no
    > file in my designated folder. The Save As is good since the user will be
    > changing the filename each time upon exiting. I'm assuming I missing some
    > code somewhere? Secondly, is there a way to save the worksheet object as
    > opposed to the entire workbook (i.e. save the worksheet into a new workbook,
    > less the VBA code preferrably)?
    >
    > Sub RenameFilenameUponClose()
    >
    > Dim SaveName As String
    > Dim fFilter As String
    > Dim NewName As String
    >
    > NewName = "P2 LogHistory Shift"
    > fFilter = "Excel Files (*.xls), *.xls"
    > SaveName = Application.GetSaveAsFilename _
    > (NewName, fileFilter:=fFilter)
    >
    > End Sub
    >
    > Your help is greatly appreciated as always.


    --

    Dave Peterson

  3. #3
    D.Parker
    Guest

    Re: No file when Save As is executed

    Thank you very much!

    "Dave Peterson" wrote:

    > This line:
    >
    > SaveName = Application.GetSaveAsFilename _
    > (NewName, fileFilter:=fFilter)
    >
    > only returns the name of the file the user chose--it doesn't do the actual save.
    >
    > Sub RenameFilenameUponClose()
    >
    > Dim SaveName As variant '<--changed
    > Dim fFilter As String
    > Dim NewName As String
    >
    > NewName = "P2 LogHistory Shift"
    > fFilter = "Excel Files (*.xls), *.xls"
    > SaveName = Application.GetSaveAsFilename _
    > (NewName, fileFilter:=fFilter)
    >
    > if savename = false then
    > 'use cancelled--what to do?
    > else
    > thisworkbook.saveas filename:=savename, fileformat:=xlworkbooknormal
    > end if
    >
    > End Sub
    >
    > I change SaveName from a String to Variant--so that it could represent the
    > boolean value False, too.
    >
    > D.Parker wrote:
    > >
    > > I am trying to save a worksheet as a separate workbook. I am manipulating
    > > code from a pervious response. The Save As form comes up and I can set a
    > > file name and choose a path, but when I click the save button there is no
    > > file in my designated folder. The Save As is good since the user will be
    > > changing the filename each time upon exiting. I'm assuming I missing some
    > > code somewhere? Secondly, is there a way to save the worksheet object as
    > > opposed to the entire workbook (i.e. save the worksheet into a new workbook,
    > > less the VBA code preferrably)?
    > >
    > > Sub RenameFilenameUponClose()
    > >
    > > Dim SaveName As String
    > > Dim fFilter As String
    > > Dim NewName As String
    > >
    > > NewName = "P2 LogHistory Shift"
    > > fFilter = "Excel Files (*.xls), *.xls"
    > > SaveName = Application.GetSaveAsFilename _
    > > (NewName, fileFilter:=fFilter)
    > >
    > > End Sub
    > >
    > > Your help is greatly appreciated as always.

    >
    > --
    >
    > Dave Peterson
    >


  4. #4
    D.Parker
    Guest

    Re: No file when Save As is executed

    Dave:

    Is there a way to save a particular worksheet into a new workbook?
    Otherwise, I will just have to password protect the code in the current
    workbook. Thanks again!

    "Dave Peterson" wrote:

    > This line:
    >
    > SaveName = Application.GetSaveAsFilename _
    > (NewName, fileFilter:=fFilter)
    >
    > only returns the name of the file the user chose--it doesn't do the actual save.
    >
    > Sub RenameFilenameUponClose()
    >
    > Dim SaveName As variant '<--changed
    > Dim fFilter As String
    > Dim NewName As String
    >
    > NewName = "P2 LogHistory Shift"
    > fFilter = "Excel Files (*.xls), *.xls"
    > SaveName = Application.GetSaveAsFilename _
    > (NewName, fileFilter:=fFilter)
    >
    > if savename = false then
    > 'use cancelled--what to do?
    > else
    > thisworkbook.saveas filename:=savename, fileformat:=xlworkbooknormal
    > end if
    >
    > End Sub
    >
    > I change SaveName from a String to Variant--so that it could represent the
    > boolean value False, too.
    >
    > D.Parker wrote:
    > >
    > > I am trying to save a worksheet as a separate workbook. I am manipulating
    > > code from a pervious response. The Save As form comes up and I can set a
    > > file name and choose a path, but when I click the save button there is no
    > > file in my designated folder. The Save As is good since the user will be
    > > changing the filename each time upon exiting. I'm assuming I missing some
    > > code somewhere? Secondly, is there a way to save the worksheet object as
    > > opposed to the entire workbook (i.e. save the worksheet into a new workbook,
    > > less the VBA code preferrably)?
    > >
    > > Sub RenameFilenameUponClose()
    > >
    > > Dim SaveName As String
    > > Dim fFilter As String
    > > Dim NewName As String
    > >
    > > NewName = "P2 LogHistory Shift"
    > > fFilter = "Excel Files (*.xls), *.xls"
    > > SaveName = Application.GetSaveAsFilename _
    > > (NewName, fileFilter:=fFilter)
    > >
    > > End Sub
    > >
    > > Your help is greatly appreciated as always.

    >
    > --
    >
    > Dave Peterson
    >


  5. #5
    Dave Peterson
    Guest

    Re: No file when Save As is executed

    You can copy a worksheet to a new workbook and save that workbook. Is that what
    you meant?

    Something like this may get you going:

    Option Explicit
    Sub testme()
    Dim wks As Worksheet
    Set wks = ActiveWorkbook.Worksheets("sheet1")

    wks.Copy 'to a new workbook
    With ActiveSheet.Parent
    .SaveAs Filename:="hithere"
    .Close savechanges:=False
    End With

    End Sub

    If you're going to overwrite an existing file, put:

    application.displayalerts = false
    ..saveas filename:=....
    application.displayalerts = true

    to suppress any "are you sure" prompt.


    D.Parker wrote:
    >
    > Dave:
    >
    > Is there a way to save a particular worksheet into a new workbook?
    > Otherwise, I will just have to password protect the code in the current
    > workbook. Thanks again!
    >
    > "Dave Peterson" wrote:
    >
    > > This line:
    > >
    > > SaveName = Application.GetSaveAsFilename _
    > > (NewName, fileFilter:=fFilter)
    > >
    > > only returns the name of the file the user chose--it doesn't do the actual save.
    > >
    > > Sub RenameFilenameUponClose()
    > >
    > > Dim SaveName As variant '<--changed
    > > Dim fFilter As String
    > > Dim NewName As String
    > >
    > > NewName = "P2 LogHistory Shift"
    > > fFilter = "Excel Files (*.xls), *.xls"
    > > SaveName = Application.GetSaveAsFilename _
    > > (NewName, fileFilter:=fFilter)
    > >
    > > if savename = false then
    > > 'use cancelled--what to do?
    > > else
    > > thisworkbook.saveas filename:=savename, fileformat:=xlworkbooknormal
    > > end if
    > >
    > > End Sub
    > >
    > > I change SaveName from a String to Variant--so that it could represent the
    > > boolean value False, too.
    > >
    > > D.Parker wrote:
    > > >
    > > > I am trying to save a worksheet as a separate workbook. I am manipulating
    > > > code from a pervious response. The Save As form comes up and I can set a
    > > > file name and choose a path, but when I click the save button there is no
    > > > file in my designated folder. The Save As is good since the user will be
    > > > changing the filename each time upon exiting. I'm assuming I missing some
    > > > code somewhere? Secondly, is there a way to save the worksheet object as
    > > > opposed to the entire workbook (i.e. save the worksheet into a new workbook,
    > > > less the VBA code preferrably)?
    > > >
    > > > Sub RenameFilenameUponClose()
    > > >
    > > > Dim SaveName As String
    > > > Dim fFilter As String
    > > > Dim NewName As String
    > > >
    > > > NewName = "P2 LogHistory Shift"
    > > > fFilter = "Excel Files (*.xls), *.xls"
    > > > SaveName = Application.GetSaveAsFilename _
    > > > (NewName, fileFilter:=fFilter)
    > > >
    > > > End Sub
    > > >
    > > > Your help is greatly appreciated as always.

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


    --

    Dave Peterson

  6. #6
    D.Parker
    Guest

    Re: No file when Save As is executed

    With the changes from your first reply, when I do a save as and go to the
    folder to check, the workbook still does not exist? I changed SaveName to
    Variant as well as NewName to Variant, would that cause the problem? Thanks
    again for you assistance.

    "Dave Peterson" wrote:

    > You can copy a worksheet to a new workbook and save that workbook. Is that what
    > you meant?
    >
    > Something like this may get you going:
    >
    > Option Explicit
    > Sub testme()
    > Dim wks As Worksheet
    > Set wks = ActiveWorkbook.Worksheets("sheet1")
    >
    > wks.Copy 'to a new workbook
    > With ActiveSheet.Parent
    > .SaveAs Filename:="hithere"
    > .Close savechanges:=False
    > End With
    >
    > End Sub
    >
    > If you're going to overwrite an existing file, put:
    >
    > application.displayalerts = false
    > ..saveas filename:=....
    > application.displayalerts = true
    >
    > to suppress any "are you sure" prompt.
    >
    >
    > D.Parker wrote:
    > >
    > > Dave:
    > >
    > > Is there a way to save a particular worksheet into a new workbook?
    > > Otherwise, I will just have to password protect the code in the current
    > > workbook. Thanks again!
    > >
    > > "Dave Peterson" wrote:
    > >
    > > > This line:
    > > >
    > > > SaveName = Application.GetSaveAsFilename _
    > > > (NewName, fileFilter:=fFilter)
    > > >
    > > > only returns the name of the file the user chose--it doesn't do the actual save.
    > > >
    > > > Sub RenameFilenameUponClose()
    > > >
    > > > Dim SaveName As variant '<--changed
    > > > Dim fFilter As String
    > > > Dim NewName As String
    > > >
    > > > NewName = "P2 LogHistory Shift"
    > > > fFilter = "Excel Files (*.xls), *.xls"
    > > > SaveName = Application.GetSaveAsFilename _
    > > > (NewName, fileFilter:=fFilter)
    > > >
    > > > if savename = false then
    > > > 'use cancelled--what to do?
    > > > else
    > > > thisworkbook.saveas filename:=savename, fileformat:=xlworkbooknormal
    > > > end if
    > > >
    > > > End Sub
    > > >
    > > > I change SaveName from a String to Variant--so that it could represent the
    > > > boolean value False, too.
    > > >
    > > > D.Parker wrote:
    > > > >
    > > > > I am trying to save a worksheet as a separate workbook. I am manipulating
    > > > > code from a pervious response. The Save As form comes up and I can set a
    > > > > file name and choose a path, but when I click the save button there is no
    > > > > file in my designated folder. The Save As is good since the user will be
    > > > > changing the filename each time upon exiting. I'm assuming I missing some
    > > > > code somewhere? Secondly, is there a way to save the worksheet object as
    > > > > opposed to the entire workbook (i.e. save the worksheet into a new workbook,
    > > > > less the VBA code preferrably)?
    > > > >
    > > > > Sub RenameFilenameUponClose()
    > > > >
    > > > > Dim SaveName As String
    > > > > Dim fFilter As String
    > > > > Dim NewName As String
    > > > >
    > > > > NewName = "P2 LogHistory Shift"
    > > > > fFilter = "Excel Files (*.xls), *.xls"
    > > > > SaveName = Application.GetSaveAsFilename _
    > > > > (NewName, fileFilter:=fFilter)
    > > > >
    > > > > End Sub
    > > > >
    > > > > Your help is greatly appreciated as always.
    > > >
    > > > --
    > > >
    > > > Dave Peterson
    > > >

    >
    > --
    >
    > Dave Peterson
    >


  7. #7
    Dave Peterson
    Guest

    Re: No file when Save As is executed

    I think if you post your current code, it would be easier to guess.

    D.Parker wrote:
    >
    > With the changes from your first reply, when I do a save as and go to the
    > folder to check, the workbook still does not exist? I changed SaveName to
    > Variant as well as NewName to Variant, would that cause the problem? Thanks
    > again for you assistance.
    >
    > "Dave Peterson" wrote:
    >
    > > You can copy a worksheet to a new workbook and save that workbook. Is that what
    > > you meant?
    > >
    > > Something like this may get you going:
    > >
    > > Option Explicit
    > > Sub testme()
    > > Dim wks As Worksheet
    > > Set wks = ActiveWorkbook.Worksheets("sheet1")
    > >
    > > wks.Copy 'to a new workbook
    > > With ActiveSheet.Parent
    > > .SaveAs Filename:="hithere"
    > > .Close savechanges:=False
    > > End With
    > >
    > > End Sub
    > >
    > > If you're going to overwrite an existing file, put:
    > >
    > > application.displayalerts = false
    > > ..saveas filename:=....
    > > application.displayalerts = true
    > >
    > > to suppress any "are you sure" prompt.
    > >
    > >
    > > D.Parker wrote:
    > > >
    > > > Dave:
    > > >
    > > > Is there a way to save a particular worksheet into a new workbook?
    > > > Otherwise, I will just have to password protect the code in the current
    > > > workbook. Thanks again!
    > > >
    > > > "Dave Peterson" wrote:
    > > >
    > > > > This line:
    > > > >
    > > > > SaveName = Application.GetSaveAsFilename _
    > > > > (NewName, fileFilter:=fFilter)
    > > > >
    > > > > only returns the name of the file the user chose--it doesn't do the actual save.
    > > > >
    > > > > Sub RenameFilenameUponClose()
    > > > >
    > > > > Dim SaveName As variant '<--changed
    > > > > Dim fFilter As String
    > > > > Dim NewName As String
    > > > >
    > > > > NewName = "P2 LogHistory Shift"
    > > > > fFilter = "Excel Files (*.xls), *.xls"
    > > > > SaveName = Application.GetSaveAsFilename _
    > > > > (NewName, fileFilter:=fFilter)
    > > > >
    > > > > if savename = false then
    > > > > 'use cancelled--what to do?
    > > > > else
    > > > > thisworkbook.saveas filename:=savename, fileformat:=xlworkbooknormal
    > > > > end if
    > > > >
    > > > > End Sub
    > > > >
    > > > > I change SaveName from a String to Variant--so that it could represent the
    > > > > boolean value False, too.
    > > > >
    > > > > D.Parker wrote:
    > > > > >
    > > > > > I am trying to save a worksheet as a separate workbook. I am manipulating
    > > > > > code from a pervious response. The Save As form comes up and I can set a
    > > > > > file name and choose a path, but when I click the save button there is no
    > > > > > file in my designated folder. The Save As is good since the user will be
    > > > > > changing the filename each time upon exiting. I'm assuming I missing some
    > > > > > code somewhere? Secondly, is there a way to save the worksheet object as
    > > > > > opposed to the entire workbook (i.e. save the worksheet into a new workbook,
    > > > > > less the VBA code preferrably)?
    > > > > >
    > > > > > Sub RenameFilenameUponClose()
    > > > > >
    > > > > > Dim SaveName As String
    > > > > > Dim fFilter As String
    > > > > > Dim NewName As String
    > > > > >
    > > > > > NewName = "P2 LogHistory Shift"
    > > > > > fFilter = "Excel Files (*.xls), *.xls"
    > > > > > SaveName = Application.GetSaveAsFilename _
    > > > > > (NewName, fileFilter:=fFilter)
    > > > > >
    > > > > > End Sub
    > > > > >
    > > > > > Your help is greatly appreciated as always.
    > > > >
    > > > > --
    > > > >
    > > > > Dave Peterson
    > > > >

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


    --

    Dave Peterson

  8. #8
    uriel78
    Guest

    Re: No file when Save As is executed

    I've got a question on this argument...How can I do to obtain a routine
    similar to the one you posted, which allows me to enter the name of the file
    in the same way I do when I choose "save as" from Fyle menu.. instead of
    typing it in the macro
    I mean I need sthg to subsitute the line

    NewName = "P2 LogHistory Shift"

    with a call for the windows displaying "save as"...

    Thanks in advance

    "Dave Peterson" <ec35720@netscapeXSPAM.com> ha scritto nel messaggio
    news:4249EAE3.C387F423@netscapeXSPAM.com...
    > This line:
    >
    > SaveName = Application.GetSaveAsFilename _
    > (NewName, fileFilter:=fFilter)
    >
    > only returns the name of the file the user chose--it doesn't do the actual

    save.
    >
    > Sub RenameFilenameUponClose()
    >
    > Dim SaveName As variant '<--changed
    > Dim fFilter As String
    > Dim NewName As String
    >
    > NewName = "P2 LogHistory Shift"
    > fFilter = "Excel Files (*.xls), *.xls"
    > SaveName = Application.GetSaveAsFilename _
    > (NewName, fileFilter:=fFilter)
    >
    > if savename = false then
    > 'use cancelled--what to do?
    > else
    > thisworkbook.saveas filename:=savename,

    fileformat:=xlworkbooknormal
    > end if
    >
    > End Sub




  9. #9
    Dave Peterson
    Guest

    Re: No file when Save As is executed

    The application.getsaveasfilename has a parameter that can be used to specify
    the initial name (if you want to "suggest" a name to the user).

    If you don't want to suggest a name at all, you can use:

    fFilter = "Excel Files (*.xls), *.xls"
    SaveName = Application.GetSaveAsFilename(InitialFileName:="", _
    fileFilter:=fFilter)

    And if you want to let excel suggest what it wants to suggest:

    fFilter = "Excel Files (*.xls), *.xls"
    SaveName = Application.GetSaveAsFilename(fileFilter:=fFilter)



    uriel78 wrote:
    >
    > I've got a question on this argument...How can I do to obtain a routine
    > similar to the one you posted, which allows me to enter the name of the file
    > in the same way I do when I choose "save as" from Fyle menu.. instead of
    > typing it in the macro
    > I mean I need sthg to subsitute the line
    >
    > NewName = "P2 LogHistory Shift"
    >
    > with a call for the windows displaying "save as"...
    >
    > Thanks in advance
    >
    > "Dave Peterson" <ec35720@netscapeXSPAM.com> ha scritto nel messaggio
    > news:4249EAE3.C387F423@netscapeXSPAM.com...
    > > This line:
    > >
    > > SaveName = Application.GetSaveAsFilename _
    > > (NewName, fileFilter:=fFilter)
    > >
    > > only returns the name of the file the user chose--it doesn't do the actual

    > save.
    > >
    > > Sub RenameFilenameUponClose()
    > >
    > > Dim SaveName As variant '<--changed
    > > Dim fFilter As String
    > > Dim NewName As String
    > >
    > > NewName = "P2 LogHistory Shift"
    > > fFilter = "Excel Files (*.xls), *.xls"
    > > SaveName = Application.GetSaveAsFilename _
    > > (NewName, fileFilter:=fFilter)
    > >
    > > if savename = false then
    > > 'use cancelled--what to do?
    > > else
    > > thisworkbook.saveas filename:=savename,

    > fileformat:=xlworkbooknormal
    > > end if
    > >
    > > End Sub


    --

    Dave Peterson

  10. #10
    uriel78
    Guest

    Re: No file when Save As is executed

    thank you for your help!!


    "Dave Peterson" <ec35720@netscapeXSPAM.com> ha scritto nel messaggio
    news:424AA4F8.B1FDC939@netscapeXSPAM.com...
    > The application.getsaveasfilename has a parameter that can be used to

    specify
    > the initial name (if you want to "suggest" a name to the user).
    >
    > If you don't want to suggest a name at all, you can use:
    >
    > fFilter = "Excel Files (*.xls), *.xls"
    > SaveName = Application.GetSaveAsFilename(InitialFileName:="", _
    > fileFilter:=fFilter)
    >
    > And if you want to let excel suggest what it wants to suggest:
    >
    > fFilter = "Excel Files (*.xls), *.xls"
    > SaveName = Application.GetSaveAsFilename(fileFilter:=fFilter)




+ 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