• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 329
  • Last Modified:

Stop wdDialogFileSaveAs from defaulting to local drive

The code below works great but if the user doesn't have access to the shared location (10.0.0.1) it defaults to a local drive. Is there a way to stop this and spit out a message saying it can't access the location due to network security or connection.

Private Sub CommandButton1_Click()
With Dialogs(wdDialogFileSaveAs)
    .Name = "\\10.0.0.1\secured1\saves\" & ActiveDocument.Name
    .Show
End With

End Sub
0
cseink
Asked:
cseink
  • 2
1 Solution
 
mvidasCommented:
Hi cseink,

Give the following a try; it should work as you need it. The Dir method will error out if the user doesn't have access to the location, so we can test to see if it returns an error or not:

Private Sub CommandButton1_Click()
 Dim vDir As String
 vDir = vbNullChar
 On Error Resume Next
 vDir = Dir("\\10.0.0.1\secured1\saves\")
 On Error GoTo 0
 If vDir = vbNullChar Then
  MsgBox "You can not access the location due to network security or connection"
 Else
  With Dialogs(wdDialogFileSaveAs)
   .Name = "\\10.0.0.1\secured1\saves\" & ActiveDocument.Name
   .Show
  End With
 End If
End Sub

Matt
0
 
cseinkAuthor Commented:
Pefect. Thanks a million
0
 
mvidasCommented:
Glad to help!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now