troubleshooting Question

vba FileDIalog box does not display Word XP

Avatar of Jenny Coulthard
Jenny CoulthardFlag for Australia asked on
Microsoft WordVB ScriptVisual Basic Classic
10 Comments1 Solution635 ViewsLast Modified:
We are using WordXP vba I am using the filedialog with msoFileDialogFilePicker to prompt the user for the name/location of a file.  the code runs OK twice but if you run the code a third time it skips over the If .Show = -1 Then and executes the code in the else portion of the statement.  It is as if the user pressed cancel but the dialog box is never displayed.

The code is run from a template.  If the code is run from the template when the template file is open no error occurs, the error only occurs when running the macros loaded through Templates and Add-ins.

Any thoughts?  

Dim dlgOpen As FileDialog
sFileName = ""
set dlgOpen = Application.FileDialog FileDialogType:=msoFileDialogFilePicker)
        With dlgOpen
            .InitialFileName = sQualityPath
            .Filters.Add Description:="All files (*.*)", Extensions:="*.*"
            .AllowMultiSelect = False
            .title = "Select EXISTING quality document"
            If .Show = -1 Then
                sFileName = .SelectedItems(1)
                'extract filename from pathname
                sFileName = UCase(Mid(sFileName, Len(sQualityPath) + 1))
                '.SelectedItems(1) = ""
                Set dlgOpen = Nothing
                MsgBox "No file selected", vbInformation, "Creat draft of next version of quality document"
                Set dlgOpen = Nothing
            End If
        End With

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 10 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros