Excel2003 corrupted VBA GUI form

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 16070
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Excel2003 corrupted VBA GUI form

Post by ChrisGreaves »

Untitled.jpg
I have shot myself in the foot, possibly by oscillating between Excel2003 and LibreOffice ODS.
I open this month's expenses workbook "2024_07.xls" and the VBA code fails because it can't find frmTransactions
The VBA code exists (lower arrow in diagram), but not the object (right-click, View Object).

When I open last month's 2024_06.xls workbook, the form is present in both Object and Code modes (UPPER arrow in diagram) and is in the Forms collection

(1) If I could r/c and "Remove" the partial form from 2024_07.xls I would do that and then drag a copy from 2024_06.XLS, but "Remove" is disabled.
(2) If I could rename that corrupted code module I'd do that and leave it there like junk DNA after dragging a fresh copy from 2024_06.
(3) I would rather NOT copy 2024_07 data sheets to a copy of 2024_06 because, well, it seems like a lot of work (there are seven data sheets in each workbook) and I am leery of further corruption. I note that the corrupted form object is sitting in the (sheets) object collection.

(3) looks like my best quick solution, unless anyone can come up with a suggestion they'd like me to try.
I don't mind experimenting on 2024_07; it is, as far as I can see, toast in any functional sense.

Thanks, Chris
You do not have the required permissions to view the files attached to this post.
The most expensive thing a man can own is ignorance.

User avatar
HansV
Administrator
Posts: 79287
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Excel2003 corrupted VBA GUI form

Post by HansV »

I'd create a new workbook.
In Excel itself, copy the worksheets from 2024_07.xls to the new workbook.
In the Visual Basic Editor, export the userform and all modules from 2024_06.xls to files (not from 2024_07.xls !).
Import those files into the new workbook.
Save the new workbook and test it.
If it works OK, delete 2024_07.xls and rename the new workbook to 2024_07.xls.
Best wishes,
Hans

User avatar
ChrisGreaves
PlutoniumLounger
Posts: 16070
Joined: 24 Jan 2010, 23:23
Location: brings.slot.perky

Re: Excel2003 corrupted VBA GUI form

Post by ChrisGreaves »

HansV wrote:
25 Jul 2024, 13:35
... In the Visual Basic Editor, export the userform and all modules from 2024_06.xls to files (not from 2024_07.xls !)....
Thank you Hans. What an interesting journey!. :clapping:
I got lazy (well it's summertime here) and decided to drag the sheets from the 2024_06 to the new Book1.
Dragging sheets from one workbook to another is a MOVE operation rather than a COPY operation. Who Knew?

When the seventh (of seven) worksheets is about to be moved, a pop-up advises that the source workbook will be closed (presumably because a workbook cannot have zero sheets), but nothing appears to be lost - neither sheet data nor sheet VBA code.

Then it was just a matter of (in VBE) dragging the frm module and the four BAS modules.
Oh Yes, and the references to the utilities library UX.XLA.

Thanks again! :thankyou:
Cheers, Chris
You do not have the required permissions to view the files attached to this post.
The most expensive thing a man can own is ignorance.