I had a document that was created in Word 2003 (vba 6.5)/Windows XP. One of the operations of this document was to open another document that the user selects when clicking on a command button. This was done through the following code.
We have now moved to a new environment; Word 2010 (VBA 7)/Windows 7.
Since this we have had problems with this code. If the files have been stored on a local drive, when the user selects a file “ “ is added to the file name e.g “”c:\file.docx””. If the file is stored on a network drive, this isn’t the case, so the selected file will be “c:\file.docx”.
Does anyone know why this is happening and whether there is a quick fix rather than having to do an IF statement to see if “” has been added to the file name and deleting if it has?
It is causing a problem because these files can be stored either on a local or network drive so I need a system that works in both scenarios.
Microsoft Word
Last Comment
jdc1944
8/22/2022 - Mon
GrahamSkan
If you are saying that the value of the variable matrixdoc is incorrect, we will need to see the code that produces it.
Chris Bottomley
How is matrixdoc defined? ... essentially ensure it is defined as a string and then this shouldn't happen ... not that I understand how it is happening but I have no such issues when using a string type variable.
Chris
jdc1944
ASKER
Sorry, the code that produces the variable is as follows:
Dim dlg As DialogDim matrixdoc As StringSet dlg = Dialogs(wdDialogFileOpen) If dlg.Display = -1 Then matrixdoc = dlg.Name End If