VBA line not working

Ezguy4u

Active Member
Joined
Feb 10, 2010
Messages
366
Office Version
  1. 365
Platform
  1. Windows
I have this program that has recently stopped working because of one line. I am getting an error message "Run-time error Automation error Invalid forward reference, or reference to uncompiled type". The program is fairly long but I have narrowed the problem down to 2 lines.
Workbooks.Open Filename:=strFile
Sheets(1).Select
When I run the program or even step thru the program the Workbooks.Open Filename:=strFile does open the workbook. Actually it opens 2 other workbooks before it just fine. It even executes Sheets(1).Select for the 2 other workbooks. But on the 3rd workbook I get the run time error. Now I make sure the 1st sheet is select just to be safe but if all the 1st sheets are selected I can comment out the Sheets(1).Select and the whole program works with no problems. Maybe somebody else has experienced this error. If my explanation isn't clear enough let me know.
Thanks for your time
Arnold
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Might be a lot easier to debug if you post ALL of the code, rather than a couple of lines.
When posting the code make sure you enclose the code in code tags....( the little VBA button on the reply toolbar
 
Upvote 0
I have this program that has recently stopped working

Something must have changed. Has the first sheet (i.e. furthest left) of the third workbook become hidden? If you compile the macro (follow the path Debug > Compile VBA Project from within the Visual Basic Editor) are there any errors? Is there an auto exec macro on the third workbook that's clashing?
 
Upvote 0
Solution
Ok so Thank you Michael for your reply. It would be the next step but the program and workbook is really big. I wanted that to be my last resort. Trebor, you motivated me to look at the workbook that the program was opening and there was one of those value change programs attached. I deleted the value change program and ran the big program and it worked. Now all the other workbooks had that same value change program, so I reinstalled the value change program and now everything is working. I don't know how the value change program workbook got changed or corrupted, but in the end, a systematic trouble shooting techniques solved the problem. Thanks all
 
Upvote 0
I don't know how the value change program workbook got changed or corrupted, but in the end, a systematic trouble shooting techniques solved the problem. Thanks all

Thanks for letting us know 👍 and you're welcome 😎
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,191
Members
452,616
Latest member
intern444

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