MrPicture15
New Member
- Joined
- Dec 2, 2013
- Messages
- 3
Hello all,
I have been reading this forum for years and have found much helpful information, so I am hoping that someone can help me out here. I've tried other solutions I found here to no effect.
What I am trying to do is provide a method for users to edit reports that are generated by an application my team developed. In order to provide the flexibility we need, the code first builds the name of the file to be opened using a string variable. Then we would open the Word document... but it keeps giving a Run-Time Error 5174 and stating that it can't find the file.
I've run Debug.Print to output the string that was created and it matches character for charater with the path and file name of the report I want to open. The report exists... it just won't open.
Here is the code we are using:
I've even tried copying the path and file name directly from Windows Explorer and it won't work... anything you can see?
I have been reading this forum for years and have found much helpful information, so I am hoping that someone can help me out here. I've tried other solutions I found here to no effect.
What I am trying to do is provide a method for users to edit reports that are generated by an application my team developed. In order to provide the flexibility we need, the code first builds the name of the file to be opened using a string variable. Then we would open the Word document... but it keeps giving a Run-Time Error 5174 and stating that it can't find the file.
I've run Debug.Print to output the string that was created and it matches character for charater with the path and file name of the report I want to open. The report exists... it just won't open.
Here is the code we are using:
Code:
Set appMS_Word = CreateObject("Word.Application")
For Each vSelected_Iterations In colSelected_Iterations
With wkbData_Workbook.Sheets("Report Data")
sReport_Name = .Range("B6").Value
sReport_Name = sReport_Name & "Reports\Extraction Reports\"
sReport_Name = sReport_Name & .Range("B1").Value
sReport_Name = sReport_Name & "_Extraction Report Iteration "
sReport_Name = sReport_Name & vSelected_Iterations & ".docx"
End With
appMS_Word.Documents.Open Filename:=sReport_Name, Format:=wdOpenFormatAuto
Next vSelected_Iterations
I've even tried copying the path and file name directly from Windows Explorer and it won't work... anything you can see?