PDA

View Full Version : Visual Basic code gets separated from workbook



macnab
07-06-2018, 05:11 AM
Excel 2007
Windows 10

Not the first time it has happened. Working with a project where the active workbook opens other workbooks. At some stage I suddenly find I have one or two of the "referenced" workbooks open, as well as the VBA editor with all my code, but the main workbook is closed.

And it can no longer be opened. If I open the workbook, the code is there, but there is no workbook. And I can't use File Save as. (Except from the VBA editor, then I still have no workbook.)

I have to export all my forms and modules and then create a new workbook and import all the files.

Is there something I can do to link the VBA code to a workbook an easier way? Or even prevent what is happening?