none
WORD SAVE DIALOG WITH VB 6.0 RRS feed

  • Question

  • Hi All.

    At the end of document assembling, I need to open a specif address "folder" and open the word 2010 save dialog at this specifc location, so the user can insert the current file name and correctly save the word document generated by my program.

    Can anyone help me how to do that? I using VB 1010 and word 2010.

    Regards.

    Tuesday, June 23, 2015 12:10 PM

All replies

  • Hi m-a-c-f

    Your information about the version of VB you're using is contradictory: VB 1010 doesn't exist; VB 2010 would be VB.NET and not VB6...

    So here's the VBA code that will do what you request

    Sub TestSaveAs()
        SaveAsToSpecifiedPath "C:\Program Files"
    End Sub
    
    Sub SaveAsToSpecifiedPath(folderPath As String)
        Dim dlg As Word.Dialog
        Set dlg = Dialogs(Word.WdWordDialog.wdDialogFileSaveAs)
        With dlg
            .Name = folderPath
            .Show
        End With
    End Sub
    


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, June 23, 2015 3:11 PM
    Moderator
  • Oh yes, you are correct. vb.net.

    But there is na error in this line. I n fact, I recorded a Macro in word, and tryed to run in vb, but it seems to be somethin wrong. May be there is some references that I need to use, please help me a little more.

    Regards.

    Set dlg = Dialogs(Word.WdWordDialog.wdDialogFileSaveAs)
    Tuesday, June 23, 2015 4:05 PM
  • It's very important when you get an error that you TELL us the error TEXT. Otherwise, it makes it very difficult to trouble shoot. I'm just guessing, here:

    1.  in VB.NET you do NOT use the keyword "Set", so leave that out.

    2. for Dialogs you need to specify the Application object: WordApp.Dialogs(....

    3. Also, I don't know how you're referencing the Word interop in your code, whether you have an Imports statement at the top and whether you've assigned an alias to it. Depending on that, the "Word." part of Word.WdWordDialog... may need to be left out or changed to the Alias you're using or be fully qualified with the interop namespace


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, June 23, 2015 4:23 PM
    Moderator
  • OK, it is almost fine.

    The problem now is that the path steel in my documents, instead of open the desire destination folder.

            Dim dlg As Word.Dialog
            dlg = WA.Dialogs(Word.WdWordDialog.wdDialogFileSaveAs)
            With dlg
                .Name = "V:\COMERCIAL\PROPOSTA COMERCIAL\"
                .Show()
            End With

    Tuesday, June 23, 2015 4:37 PM
  • That´s work!!!

    But I cannot reach the server folder, although I have all necessary permissions. How to fix this?

            Dim dlg As Word.Dialog
            dlg = WA.Dialogs(Word.WdWordDialog.wdDialogFileSaveAs)
            With dlg
                .Name = "\\192.168.1.12\geral\COMERCIAL\PROPOSTA COMERCIAL\"
                .Show()
            End With


    Tuesday, June 23, 2015 4:47 PM
  • It's important to realize that the dialog box technology dates back to the early 1990s and so sometimes has difficulties with non-local folder addresses.

    What happens if you display the dialog box in the UI, as a user, and try to access this address? Can you? If you can, what information does Word show in the Address bar at the top of the dialog box?


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, June 23, 2015 5:34 PM
    Moderator