wardw
03-14-2016, 01:41 PM
I'm fairly new to VBA, and I'm learning how to build a macro with a dialog box that prompts for a Word document to open, opens the document, makes some changes, and saves it. The dialog has a dropdown list of available documents.
When I choose my document in the dialog (in this case it's Latest Report.docx) and click OK, I get a message:
"This file could not be found. ("C:\Users\...\WWME\Latest Report.docx")".
The portion of the dialog box code that points to the document is:
Documents.Open FileName:=Environ("userprofile") & "Documents\WMME\" & cmbSourceDocument.Value
I've checked my Windows userprofile, and it's correct. A file with the name Latest Report.docx is in the correct directory. I tried just citing the literal path to the document like this:
Documents.Open FileName:="C:\Users\Ward\Documents\WMME\Source Document.dotx"
but the same error appears. How can I direct the macro to the correct document?
I'm using Visual Basic 6.5, Word 2007, on a Windows 10 PC.
When I choose my document in the dialog (in this case it's Latest Report.docx) and click OK, I get a message:
"This file could not be found. ("C:\Users\...\WWME\Latest Report.docx")".
The portion of the dialog box code that points to the document is:
Documents.Open FileName:=Environ("userprofile") & "Documents\WMME\" & cmbSourceDocument.Value
I've checked my Windows userprofile, and it's correct. A file with the name Latest Report.docx is in the correct directory. I tried just citing the literal path to the document like this:
Documents.Open FileName:="C:\Users\Ward\Documents\WMME\Source Document.dotx"
but the same error appears. How can I direct the macro to the correct document?
I'm using Visual Basic 6.5, Word 2007, on a Windows 10 PC.