Consulting

Results 1 to 4 of 4

Thread: save a file using vba and the file dialog

  1. #1

    save a file using vba and the file dialog

    I'm trying to put in code to save the active presentation using the file dialog box. I can get the dialog box to appear with this:

    Application.FileDialog(msoFileDialogSaveAs).Title = _
    "Random Title For Dialog"
    'make the file dialog visible to the user 
    intChoice = Application.FileDialog(msoFileDialogSaveAs).Show
    'determine what choice the user made 
    If intChoice <> 0 Then 
    'your code here"
    End If 
    End Sub
    But I don't understand what I need to change so that the file name I type in the dialog box is saved. The "intChoice" variable above doesn't seem to do anything, whether I select a file, or type a new name in. What code do I need in the "your code here" part of this routine? I tried "activepresentation.save", and it did, but saved the file as "-1" and not with the name I typed in the dialog box.

    Thanks for anyone's help.

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    Googling for msoFileDialogSaveAs finds lots of examples

    http://software-solutions-online.com...edialogsaveas/



    Sub  Example1()
    Dim  intChoice As  Integer 
    Dim  strPath As  String 
    
    'make the file dialog visible to the user 
    intChoice = Application.FileDialog(msoFileDialogSaveAs).Show
    
    'determine what choice the user made 
    If  intChoice <> 0 Then 
    
        'get the file path selected by the user 
        strPath = Application.FileDialog(msoFileDialogSaveAs).SelectedItems(1) 
    
        'displays the result in a message box 
         Call  MsgBox(strPath, vbInformation, "Save Path")
    
    End If 
    End  Sub
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    Thanks Paul... works great!

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,726
    Location
    Glad

    You can mark this [Solved] by going to [Thread Tools] above your first post and clicking the radio button
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Posting Permissions

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