I am trying to write a visual basic (VS 2017) program which will open as many as six different Excel workbooks. When the program loads it will open two separate workbooks which will be used for reference information. Another button (sub) will open as many as four separate workbooks based on user selection from a listbox.
After that, data will be entered directly into each of the four workbooks individually outside of the visual basic program. When all of the data have been entered into the individual workbooks, I will click a button (sub) on the visual basic form which will close all of the open spreadsheets.
When I run the sub that is supposed to close the files, I get a message that says: "Object reference not set to an instance of an object."
What do I have to do to make this work?
What I have tried:
I have stumbled around trying to change the dim statements, such as
Dim wb as new Excel.workbook, etc, etc
I don't know what else to try.