Extracting modules from a different workbook via VBA? (corrupt file)

dispelthemyth

Well-known Member
Joined
Mar 16, 2006
Messages
664
Office Version
  1. 365
Platform
  1. Windows
I have a corrupt file that i cant expand the project view on meaning i cant get to the point of seeing the modules and right clicking to export (it is password protecting and i am able to enter the password successfully)

Is there a way to export these modules using VBA when inside another workbook?
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
I have a corrupt file that i cant expand the project view on meaning i cant get to the point of seeing the modules and right clicking to export (it is password protecting and i am able to enter the password successfully)

Is there a way to export these modules using VBA when inside another workbook?

Have you tried something like this assuming the corrupt excel file and the expoting workbook are both opened in the same excel instance:

Code:
Call Workbooks("[COLOR=#ff0000][B]Book2[/B][/COLOR]").VBProject.VBComponents("[COLOR=#ff0000][B]Module1[/B][/COLOR]").Export(...

Change the items in red to suit.
 
Last edited:
Upvote 0
Have you tried something like this assuming the corrupt excel file and the expoting workbook are both opened in the same excel instance:

Code:
Call Workbooks("[COLOR=#ff0000][B]Book2[/B][/COLOR]").VBProject.VBComponents("[COLOR=#ff0000][B]Module1[/B][/COLOR]").Export(...

Change the items in red to suit.

Thank you very much for the helpful code, i've been able to amend it to cycle through all the objects and extract. much appreciated.
 
Upvote 0

Forum statistics

Threads
1,214,528
Messages
6,120,065
Members
448,941
Latest member
AlphaRino

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