Stop wdDialogFileSaveAs from defaulting to local drive

Posted on 2007-10-03
Last Modified: 2012-06-27
The code below works great but if the user doesn't have access to the shared location ( 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 = "\\\secured1\saves\" & ActiveDocument.Name
End With

End Sub
Question by:cseink
    LVL 35

    Accepted Solution

    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("\\\secured1\saves\")
     On Error GoTo 0
     If vDir = vbNullChar Then
      MsgBox "You can not access the location due to network security or connection"
      With Dialogs(wdDialogFileSaveAs)
       .Name = "\\\secured1\saves\" & ActiveDocument.Name
      End With
     End If
    End Sub


    Author Comment

    Pefect. Thanks a million
    LVL 35

    Expert Comment

    Glad to help!

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
    Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
    Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
    Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now