+ Reply to Thread
Results 1 to 7 of 7

Need VBA code for Save As dialog

  1. #1
    Bill Sturdevant
    Guest

    Need VBA code for Save As dialog

    I am trying to create a button that will pick a value from a specified cell
    and put up a Save As dialog pre-filled with the name of the file as
    Value-I-Picked.xls and the suggested path as the path of the workbook I
    originally opened.

    Where can I find suggestions for appropriate code?

  2. #2
    Chip Pearson
    Guest

    Re: Need VBA code for Save As dialog

    Bill,

    Use code like the following:

    Dim FName As Variant
    FName = Application.GetSaveAsFilename( _
    InitialFileName:="MyFile.xls", _
    filefilter:="Excel Files (*.xls),*.xls")
    If FName = False Then
    ' user cancelled
    Else
    ' user selected FName
    End If


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com



    "Bill Sturdevant" <[email protected]>
    wrote in message
    news:[email protected]...
    >I am trying to create a button that will pick a value from a
    >specified cell
    > and put up a Save As dialog pre-filled with the name of the
    > file as
    > Value-I-Picked.xls and the suggested path as the path of the
    > workbook I
    > originally opened.
    >
    > Where can I find suggestions for appropriate code?




  3. #3
    Tom Ogilvy
    Guest

    Re: Need VBA code for Save As dialog

    sStr = Thisworkbook.Path & "\" & activecell.value & ".xls"

    fname = application.GetSaveAsFileName( InitialFileName:=sStr)

    --
    Regards,
    Tom Ogilvy




    "Bill Sturdevant" <[email protected]> wrote in
    message news:[email protected]...
    > I am trying to create a button that will pick a value from a specified

    cell
    > and put up a Save As dialog pre-filled with the name of the file as
    > Value-I-Picked.xls and the suggested path as the path of the workbook I
    > originally opened.
    >
    > Where can I find suggestions for appropriate code?




  4. #4
    Jim Thomlinson
    Guest

    Re: Need VBA code for Save As dialog

    To get the save as dialog use

    Application.Dialogs(xlDialogSaveAs).Show fname

    HTH

    "Tom Ogilvy" wrote:

    > sStr = Thisworkbook.Path & "\" & activecell.value & ".xls"
    >
    > fname = application.GetSaveAsFileName( InitialFileName:=sStr)
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    >
    >
    > "Bill Sturdevant" <[email protected]> wrote in
    > message news:[email protected]...
    > > I am trying to create a button that will pick a value from a specified

    > cell
    > > and put up a Save As dialog pre-filled with the name of the file as
    > > Value-I-Picked.xls and the suggested path as the path of the workbook I
    > > originally opened.
    > >
    > > Where can I find suggestions for appropriate code?

    >
    >
    >


  5. #5
    Jim Thomlinson
    Guest

    Re: Need VBA code for Save As dialog

    Sorry I accidentally hit post too fast. Tom. What is the difference between

    Application.Dialogs(xlDialogSaveAs).Show sStr

    and

    fname = application.GetSaveAsFileName( InitialFileName:=sStr)

    ?

    "Jim Thomlinson" wrote:

    > To get the save as dialog use
    >
    > Application.Dialogs(xlDialogSaveAs).Show fname
    >
    > HTH
    >
    > "Tom Ogilvy" wrote:
    >
    > > sStr = Thisworkbook.Path & "\" & activecell.value & ".xls"
    > >
    > > fname = application.GetSaveAsFileName( InitialFileName:=sStr)
    > >
    > > --
    > > Regards,
    > > Tom Ogilvy
    > >
    > >
    > >
    > >
    > > "Bill Sturdevant" <[email protected]> wrote in
    > > message news:[email protected]...
    > > > I am trying to create a button that will pick a value from a specified

    > > cell
    > > > and put up a Save As dialog pre-filled with the name of the file as
    > > > Value-I-Picked.xls and the suggested path as the path of the workbook I
    > > > originally opened.
    > > >
    > > > Where can I find suggestions for appropriate code?

    > >
    > >
    > >


  6. #6
    Chip Pearson
    Guest

    Re: Need VBA code for Save As dialog

    Jim,

    GetSaveAsFileName simply returns a filename (or False if the user
    cancels the dialog). It doesn't actually do the save. Displaying
    the xlDialogSaveAs will carry out the save operation.


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com




    "Jim Thomlinson" <[email protected]> wrote
    in message
    news:[email protected]...
    > Sorry I accidentally hit post too fast. Tom. What is the
    > difference between
    >
    > Application.Dialogs(xlDialogSaveAs).Show sStr
    >
    > and
    >
    > fname = application.GetSaveAsFileName( InitialFileName:=sStr)
    >
    > ?
    >
    > "Jim Thomlinson" wrote:
    >
    >> To get the save as dialog use
    >>
    >> Application.Dialogs(xlDialogSaveAs).Show fname
    >>
    >> HTH
    >>
    >> "Tom Ogilvy" wrote:
    >>
    >> > sStr = Thisworkbook.Path & "\" & activecell.value & ".xls"
    >> >
    >> > fname = application.GetSaveAsFileName(
    >> > InitialFileName:=sStr)
    >> >
    >> > --
    >> > Regards,
    >> > Tom Ogilvy
    >> >
    >> >
    >> >
    >> >
    >> > "Bill Sturdevant" <[email protected]>
    >> > wrote in
    >> > message
    >> > news:[email protected]...
    >> > > I am trying to create a button that will pick a value from
    >> > > a specified
    >> > cell
    >> > > and put up a Save As dialog pre-filled with the name of
    >> > > the file as
    >> > > Value-I-Picked.xls and the suggested path as the path of
    >> > > the workbook I
    >> > > originally opened.
    >> > >
    >> > > Where can I find suggestions for appropriate code?
    >> >
    >> >
    >> >




  7. #7
    Jim Thomlinson
    Guest

    Re: Need VBA code for Save As dialog

    Thanks... That was quicker than looking it up... :-)

    "Chip Pearson" wrote:

    > Jim,
    >
    > GetSaveAsFileName simply returns a filename (or False if the user
    > cancels the dialog). It doesn't actually do the save. Displaying
    > the xlDialogSaveAs will carry out the save operation.
    >
    >
    > --
    > Cordially,
    > Chip Pearson
    > Microsoft MVP - Excel
    > Pearson Software Consulting, LLC
    > www.cpearson.com
    >
    >
    >
    >
    > "Jim Thomlinson" <[email protected]> wrote
    > in message
    > news:[email protected]...
    > > Sorry I accidentally hit post too fast. Tom. What is the
    > > difference between
    > >
    > > Application.Dialogs(xlDialogSaveAs).Show sStr
    > >
    > > and
    > >
    > > fname = application.GetSaveAsFileName( InitialFileName:=sStr)
    > >
    > > ?
    > >
    > > "Jim Thomlinson" wrote:
    > >
    > >> To get the save as dialog use
    > >>
    > >> Application.Dialogs(xlDialogSaveAs).Show fname
    > >>
    > >> HTH
    > >>
    > >> "Tom Ogilvy" wrote:
    > >>
    > >> > sStr = Thisworkbook.Path & "\" & activecell.value & ".xls"
    > >> >
    > >> > fname = application.GetSaveAsFileName(
    > >> > InitialFileName:=sStr)
    > >> >
    > >> > --
    > >> > Regards,
    > >> > Tom Ogilvy
    > >> >
    > >> >
    > >> >
    > >> >
    > >> > "Bill Sturdevant" <[email protected]>
    > >> > wrote in
    > >> > message
    > >> > news:[email protected]...
    > >> > > I am trying to create a button that will pick a value from
    > >> > > a specified
    > >> > cell
    > >> > > and put up a Save As dialog pre-filled with the name of
    > >> > > the file as
    > >> > > Value-I-Picked.xls and the suggested path as the path of
    > >> > > the workbook I
    > >> > > originally opened.
    > >> > >
    > >> > > Where can I find suggestions for appropriate code?
    > >> >
    > >> >
    > >> >

    >
    >
    >


+ 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