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.
Dim dlgOpen As FileDialogsFileName = ""set dlgOpen = Application.FileDialog FileDialogType:=msoFileDialogFilePicker) With dlgOpen .Filters.Clear .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 Else Beep MsgBox "No file selected", vbInformation, "Creat draft of next version of quality document" Set dlgOpen = Nothing Main End If End With
Hopefully that should remove it from memory and this problem should disappear (famous last words)