Trying to Open a Word Doc in Excel VBa... Run-Time Error 5174

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:

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?
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
My apologies, I realized I did not post the relevant Excel and Windows version information. The application runs in Windows 7 64-bit using Excel 2010 32-bit. Thank you!
 
Upvote 0

Forum statistics

Threads
1,221,849
Messages
6,162,425
Members
451,765
Latest member
craigvan888

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top