jagrenet
Board Regular
- Joined
- Feb 23, 2022
- Messages
- 81
- Office Version
- 365
- 2013
- 2011
- 2010
- Platform
- Windows
I am using a couple of variables with a DIR function and, while the first variable works just fine, the second doesn't.
Dim Path As String
Dim PSAP_Name As String
Dim AppAvail As String
PSAP_Name = Worksheets("Sheet1").Range("C5") - (Cell C5 contains the word WALTON)
Path = "C:\Monthly_Reports\" & PSAP_Name & "\"
AppAvail = Dir(Path & "Application Availability*.docx")
OpenFile = Path & AppAvail
Set wd = New Word.Application
wd.Visible = True
wd.DisplayAlerts = wdAlertsNone
Set doc = wd.Documents.Open(OpenFile, ReadOnly)
As I step through the code I can see that "Path" actually reads "C:\Monthly_Reports\WALTON\", like it is supposed to.
When I look at the variable "AppAvail" it only shows "C:\Monthly_Reports\WALTON\" but does not include the filename specified - "Appllication Availablity*.docx".
I'm not exactly sure what I am missing here.
Thank you in advance,
Jeff
Dim Path As String
Dim PSAP_Name As String
Dim AppAvail As String
PSAP_Name = Worksheets("Sheet1").Range("C5") - (Cell C5 contains the word WALTON)
Path = "C:\Monthly_Reports\" & PSAP_Name & "\"
AppAvail = Dir(Path & "Application Availability*.docx")
OpenFile = Path & AppAvail
Set wd = New Word.Application
wd.Visible = True
wd.DisplayAlerts = wdAlertsNone
Set doc = wd.Documents.Open(OpenFile, ReadOnly)
As I step through the code I can see that "Path" actually reads "C:\Monthly_Reports\WALTON\", like it is supposed to.
When I look at the variable "AppAvail" it only shows "C:\Monthly_Reports\WALTON\" but does not include the filename specified - "Appllication Availablity*.docx".
I'm not exactly sure what I am missing here.
Thank you in advance,
Jeff