We have been running Word 2000 and have built a number of macros to streamline users access to our document storage location. The macro in 2000 simply changes the file open directory based on an input from the user and sets this as the File open directory path and using Word built in WdFileOpenDialog command to display the file open box. All is fine. Example below
Works everytime in Word 2000
ChangeFileOpenDirectory (Cpath1 + MyValue + "\")
With Dialogs(wdDialogFileOpen)
.Name = "*"
.Show
End With
'Cpath1 is a url location based on the users login server
'MyValue is the numeric value inputted by the user into a textbox.
'The "\" was added to try to solve the issue in 2003. Not needed in 2000.
Upon moving to Word 2003 we have noticed a number of issues relating to this. The first one, which crops up on other forums is that when you set the file open directory using ChangeFileOpenDirectory the directory returned is not always the right one but reverts to the My Documents folder. This does not happen on all machines and seems to be based on the speed of the machine and how fast it executes the code. Slower machines are better but it still can be hit and miss which seems to suggest the code itself is fine. If you step the code it works everytime which also seems to point to speed.
I have tried introducing pauses using step but no matter where or how many i put in the result is inconsistant.
I then tried a different approach by using the following code (that does not run in 2000 as it is not supported)
dirpath = Cpath1 + MyValue
Set fd = Application.FileDialog(mso
FileDialog
Open)
fd.InitialFileName = dirpath + "\*.*"
If fd.Show Then
Application.Documents.Open
fd.SelectedItems(1)
fd.Execute
End If
Set fd = Nothing
Exit Sub
This code albeit not the polished article works fine. The correct directory is returned everytime however the file open dialog does not seem to provide all the features of the Menu File,Open Dialog box. the main one that does not work is selecting Preview as the Initial View. You get a "preview is not available" message in the dialog box. We don't want to use Word 2003 saved preview option which creates a minature copy of the enitre first page as this is so small you can't use it but instead the standard preview option in File,Open which shows the first x characters of the selected document.
So I guess I have two questions:
1. Can the changefileopendirectory work consistantly in Word 2003?
2. Can the preview functionality of the stanard open dialog box be available when using msoFileDialogOpen?
Any guidance would be welcome.
Al
Start Free Trial