Bra Utbildning AB

 

<-- Back
VBA & Object models
Work with text
Bookmarks
Ranges
Fields
Form fields
Autotext
Doc var & Doc Prop
Built-in commands
Built-in dialogs
Automation
External databases

Work with built-in dialogs


Show the dialog SaveAs
Dialogs(wdDialogFileSaveAs).Show

Show the SaveAs dialog with a predefined file name
With Dialogs(wdDialogFileSaveAs)
   .Name = "You add a file name suggestion here"
   .Show
End With

In this example the SaveAs dialog is made visible with a predefined file name. When the user dismiss' the dialog you verify both which button was selected (OK/Cancel) and the length of the file name. If a shorter file name than 22 characters (puh..) is entered you make sure that the file is not being saved and the user is made aware of the fact. 


With Dialogs(wdDialogFileSaveAs)
   .Name = "You add a file name suggestion here"
    If .Display = -1 Then
      If Len(.Name) < 22 Then
         Msgbox "The file name is too short. The document will not be saved."
      Else
         .Execute
      End If
   End If
End With

Use a built-in dialog to select a folder/directory. Warning! Certain OS will return the path enclosed in quotation marks. 
With Dialogs(wdDialogCopyFile)
      .Display
      sFolder = .Directory
End With

MsgBox "The selected folder is " & sFolder