Workbooks.Open Issue

Toast83

New Member
Joined
Feb 4, 2013
Messages
8
Good Afternoon,

I'm still new to VBA, so bear with me as I try and explain my problem...

I am using a VBA in Word to pull information from an Excel file to populate my document. The Excel file is the result of a process that I have no control over and don't have the ability to change but a few select fields.

I use the following code to access the Excel Workbook that I need.


Set XlApp = New Excel.Application
Set XlWb = XlApp.Workbooks.Open(ActiveDocument.Path & "\Fund Action Submittal Form.xls", ReadOnly:=True)


The problem is that the Workbook asks to save even if no changes are made. So, when my macro is done, Excel still thinks that the Workbook is open because the user didn't choose whether or not to save the file - for lack of a better description. So, when I open antoher Excel file, the "Fund Action Submittal Form" opens in the window behind it. If I run the VBA 5 times, the file will open with the next 5 Excel files that I open.

Any thoughts on how to rememdy this are welcome!


Best Regards

RCT
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
I am not sure of the syntax from the Word side, but you probably need something near the end of the macro like:

Code:
XlApp.XlWb.Saved=True
XlApp.XlWb.Close
XlApp.Quit
Untested
 
Upvote 0
Had to tweak it slightly. Ended up looking like this:

Code:
XlWb.Saved = True
XlWb.Close
XlApp.Quit

Works like a charm, now. Thanks for the idea!


Best Regards,

RCT
 
Upvote 0

Forum statistics

Threads
1,215,046
Messages
6,122,854
Members
449,096
Latest member
Erald

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