+ Reply to Thread
Results 1 to 6 of 6

Allowing the user to specify save location

Hybrid View

  1. #1
    TimN
    Guest

    Allowing the user to specify save location

    Easy question I'm sure.....

    How do I write code to save a file as the name in cell C2 but also allow the
    user to define the location (path) of the file?

    What I would like is the same as the window that pops up when you select
    File>> Save As in Excel. If I could get the file name to default (from cell
    C2) and then have the user take it from there to save to the location they
    want.

    How can I get there?

    I currently have the code below:

    Application.DisplayAlerts = False
    ActiveWorkbook.SaveAs Filename:=Range("C2").Value
    Application.DisplayAlerts = True

  2. #2
    News
    Guest

    Re: Allowing the user to specify save location

    Tim,
    You mean like this ?

    Private Sub CommandButton3_Click()
    Dim RetVal As Variant
    RetVal = Application.GetSaveAsFilename(Range("C2"))
    If RetVal <> False Then
    ThisWorkbook.SaveAs RetVal
    End If
    End Sub

    NickHK

    "TimN" <[email protected]> 级糶秎ン穝籇:[email protected]...
    > Easy question I'm sure.....
    >
    > How do I write code to save a file as the name in cell C2 but also allow
    > the
    > user to define the location (path) of the file?
    >
    > What I would like is the same as the window that pops up when you select
    > File>> Save As in Excel. If I could get the file name to default (from
    > cell
    > C2) and then have the user take it from there to save to the location they
    > want.
    >
    > How can I get there?
    >
    > I currently have the code below:
    >
    > Application.DisplayAlerts = False
    > ActiveWorkbook.SaveAs Filename:=Range("C2").Value
    > Application.DisplayAlerts = True




  3. #3
    Die_Another_Day
    Guest

    Re: Allowing the user to specify save location

    Tim, try this:
    Sub FolderPicker()
    Dim SvPath As String
    With Application.FileDialog(msoFileDialogFolderPicker)
    .AllowMultiSelect =3D False
    If .Show =3D False Then Exit Sub
    SvPath =3D .SelectedItems(1)
    End With
    ActiveWorkbook.SaveAs SvPath & Range("C1")
    End Sub

    Charles
    News wrote:
    > Tim,
    > You mean like this ?
    >
    > Private Sub CommandButton3_Click()
    > Dim RetVal As Variant
    > RetVal =3D Application.GetSaveAsFilename(Range("C2"))
    > If RetVal <> False Then
    > ThisWorkbook.SaveAs RetVal
    > End If
    > End Sub
    >
    > NickHK
    >
    > "TimN" <[email protected]> =BC=B6=BCg=A9=F3=B6l=A5=F3=B7s=BB=

    D:[email protected]...
    > > Easy question I'm sure.....
    > >
    > > How do I write code to save a file as the name in cell C2 but also allow
    > > the
    > > user to define the location (path) of the file?
    > >
    > > What I would like is the same as the window that pops up when you select
    > > File>> Save As in Excel. If I could get the file name to default (from
    > > cell
    > > C2) and then have the user take it from there to save to the location t=

    hey
    > > want.
    > >
    > > How can I get there?
    > >
    > > I currently have the code below:
    > >
    > > Application.DisplayAlerts =3D False
    > > ActiveWorkbook.SaveAs Filename:=3DRange("C2").Value
    > > Application.DisplayAlerts =3D True



  4. #4
    TimN
    Guest

    Re: Allowing the user to specify save location

    Thanks to both of you. These worked great! One question just out of
    curiosity. When I do the save, it saves the file as a file type "File"
    rather than an excel worksheet (.xls). What is file type "file"?

    "Die_Another_Day" wrote:

    > Tim, try this:
    > Sub FolderPicker()
    > Dim SvPath As String
    > With Application.FileDialog(msoFileDialogFolderPicker)
    > .AllowMultiSelect = False
    > If .Show = False Then Exit Sub
    > SvPath = .SelectedItems(1)
    > End With
    > ActiveWorkbook.SaveAs SvPath & Range("C1")
    > End Sub
    >
    > Charles
    > News wrote:
    > > Tim,
    > > You mean like this ?
    > >
    > > Private Sub CommandButton3_Click()
    > > Dim RetVal As Variant
    > > RetVal = Application.GetSaveAsFilename(Range("C2"))
    > > If RetVal <> False Then
    > > ThisWorkbook.SaveAs RetVal
    > > End If
    > > End Sub
    > >
    > > NickHK
    > >
    > > "TimN" <[email protected]> 录露录g漏贸露l楼贸路s禄D:[email protected]...
    > > > Easy question I'm sure.....
    > > >
    > > > How do I write code to save a file as the name in cell C2 but also allow
    > > > the
    > > > user to define the location (path) of the file?
    > > >
    > > > What I would like is the same as the window that pops up when you select
    > > > File>> Save As in Excel. If I could get the file name to default (from
    > > > cell
    > > > C2) and then have the user take it from there to save to the location they
    > > > want.
    > > >
    > > > How can I get there?
    > > >
    > > > I currently have the code below:
    > > >
    > > > Application.DisplayAlerts = False
    > > > ActiveWorkbook.SaveAs Filename:=Range("C2").Value
    > > > Application.DisplayAlerts = True

    >
    >


  5. #5
    Die_Another_Day
    Guest

    Re: Allowing the user to specify save location

    Try:
    ActiveWorkbook.SaveAs Filename:=3D _
    SvPath & Range("C1"), _
    FileFormat:=3DxlNormal

    Let me know if that fixes things.

    Charles

    TimN wrote:
    > Thanks to both of you. These worked great! One question just out of
    > curiosity. When I do the save, it saves the file as a file type "File"
    > rather than an excel worksheet (.xls). What is file type "file"?
    >
    > "Die_Another_Day" wrote:
    >
    > > Tim, try this:
    > > Sub FolderPicker()
    > > Dim SvPath As String
    > > With Application.FileDialog(msoFileDialogFolderPicker)
    > > .AllowMultiSelect =3D False
    > > If .Show =3D False Then Exit Sub
    > > SvPath =3D .SelectedItems(1)
    > > End With
    > > ActiveWorkbook.SaveAs SvPath & Range("C1")
    > > End Sub
    > >
    > > Charles
    > > News wrote:
    > > > Tim,
    > > > You mean like this ?
    > > >
    > > > Private Sub CommandButton3_Click()
    > > > Dim RetVal As Variant
    > > > RetVal =3D Application.GetSaveAsFilename(Range("C2"))
    > > > If RetVal <> False Then
    > > > ThisWorkbook.SaveAs RetVal
    > > > End If
    > > > End Sub
    > > >
    > > > NickHK
    > > >
    > > > "TimN" <[email protected]> =BC=B6=BCg=A9=F3=B6l=A5=F3=B7=

    s=BBD:[email protected]...
    > > > > Easy question I'm sure.....
    > > > >
    > > > > How do I write code to save a file as the name in cell C2 but also =

    allow
    > > > > the
    > > > > user to define the location (path) of the file?
    > > > >
    > > > > What I would like is the same as the window that pops up when you s=

    elect
    > > > > File>> Save As in Excel. If I could get the file name to default (=

    from
    > > > > cell
    > > > > C2) and then have the user take it from there to save to the locati=

    on they
    > > > > want.
    > > > >
    > > > > How can I get there?
    > > > >
    > > > > I currently have the code below:
    > > > >
    > > > > Application.DisplayAlerts =3D False
    > > > > ActiveWorkbook.SaveAs Filename:=3DRange("C2").Value
    > > > > Application.DisplayAlerts =3D True

    > >=20
    > >



  6. #6
    News
    Guest

    Re: Allowing the user to specify save location

    Which format was was the original file in and how do you .SaveAs ?

    NickHK

    "TimN" <[email protected]> 级糶秎ン穝籇:[email protected]...
    > Thanks to both of you. These worked great! One question just out of
    > curiosity. When I do the save, it saves the file as a file type "File"
    > rather than an excel worksheet (.xls). What is file type "file"?
    >
    > "Die_Another_Day" wrote:
    >
    >> Tim, try this:
    >> Sub FolderPicker()
    >> Dim SvPath As String
    >> With Application.FileDialog(msoFileDialogFolderPicker)
    >> .AllowMultiSelect = False
    >> If .Show = False Then Exit Sub
    >> SvPath = .SelectedItems(1)
    >> End With
    >> ActiveWorkbook.SaveAs SvPath & Range("C1")
    >> End Sub
    >>
    >> Charles
    >> News wrote:
    >> > Tim,
    >> > You mean like this ?
    >> >
    >> > Private Sub CommandButton3_Click()
    >> > Dim RetVal As Variant
    >> > RetVal = Application.GetSaveAsFilename(Range("C2"))
    >> > If RetVal <> False Then
    >> > ThisWorkbook.SaveAs RetVal
    >> > End If
    >> > End Sub
    >> >
    >> > NickHK
    >> >
    >> > "TimN" <[email protected]> ???gco?los?D:[email protected]...
    >> >
    >> > > Easy question I'm sure.....
    >> > >
    >> > > How do I write code to save a file as the name in cell C2 but also
    >> > > allow
    >> > > the
    >> > > user to define the location (path) of the file?
    >> > >
    >> > > What I would like is the same as the window that pops up when you
    >> > > select
    >> > > File>> Save As in Excel. If I could get the file name to default
    >> > > (from
    >> > > cell
    >> > > C2) and then have the user take it from there to save to the location
    >> > > they
    >> > > want.
    >> > >
    >> > > How can I get there?
    >> > >
    >> > > I currently have the code below:
    >> > >
    >> > > Application.DisplayAlerts = False
    >> > > ActiveWorkbook.SaveAs Filename:=Range("C2").Value
    >> > > Application.DisplayAlerts = True

    >>
    >>




+ 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