Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Extracting (copying) modules from one workbook to another.

Hi,
I screwed up, bigtime, and now I cannot open one of my workbooks. However, I
really want to recover the project stored in it. All I need to do is somehow
extract that data from the workbook without opening it. I have tried the
Office tool 'recover data' but when it repairs the file it deletes the macros
(yes, they are that screwed up :P ). I found a website that offers a 'copy
all modules to another workbook' program for VBE, but trying it in the VBA
editor from excel doesn't work. If the program did work I think it would
solve my problem. Here is the code from that website:


Sub CopyAllModules()

Dim FName As String
Dim VBComp As VBIDE.VBComponent

With Workbooks("Book2")
FName = .Path & "\code.txt"
If Dir(FName) < "" Then
Kill FName
End If
For Each VBComp In .VBProject.VBComponents
If VBComp.Type < vbext_ct_Document Then
VBComp.Export FName
Workbooks("book1").VBProject.VBComponents.Import FName
Kill FName
End If
Next VBComp
End With
End Sub

It is the 'VBIDE.VBComponent' that doesn't work (not registered in VBA?) and
I think that the 'VBComponents' doesn't work either. The website is
http://www.cpearson.com/excel/vbe.htm .
Can someone help me recover my project?
Thanks ahead of time for the help (once again)
Devin L.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 230
Default Extracting (copying) modules from one workbook to another.

If you cannot open the workbook manually, then a VBA macro like the below
can't work on it. The below is for copying code out of an open workbooks.
Sorry I cannot help you further.



"Devin Linnington" wrote in
message ...
Hi,
I screwed up, bigtime, and now I cannot open one of my workbooks. However,
I
really want to recover the project stored in it. All I need to do is
somehow
extract that data from the workbook without opening it. I have tried the
Office tool 'recover data' but when it repairs the file it deletes the
macros
(yes, they are that screwed up :P ). I found a website that offers a 'copy
all modules to another workbook' program for VBE, but trying it in the VBA
editor from excel doesn't work. If the program did work I think it would
solve my problem. Here is the code from that website:


Sub CopyAllModules()

Dim FName As String
Dim VBComp As VBIDE.VBComponent

With Workbooks("Book2")
FName = .Path & "\code.txt"
If Dir(FName) < "" Then
Kill FName
End If
For Each VBComp In .VBProject.VBComponents
If VBComp.Type < vbext_ct_Document Then
VBComp.Export FName
Workbooks("book1").VBProject.VBComponents.Import FName
Kill FName
End If
Next VBComp
End With
End Sub

It is the 'VBIDE.VBComponent' that doesn't work (not registered in VBA?)
and
I think that the 'VBComponents' doesn't work either. The website is
http://www.cpearson.com/excel/vbe.htm .
Can someone help me recover my project?
Thanks ahead of time for the help (once again)
Devin L.





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
copying modules from one workbook to another workbook Vinod[_2_] Excel Discussion (Misc queries) 3 September 19th 08 06:18 PM
Extracting Modules to Compressed Windows Folders Harlan Grove Excel Programming 2 May 25th 05 03:30 PM
Copying VBA modules from one workbook to another with a macro? Revolvr[_2_] Excel Programming 2 May 6th 04 11:04 AM
Copy Modules from One workbook to Active Workbook Jim Gifford Excel Programming 1 November 18th 03 12:30 PM
Copying modules Steven Revell Excel Programming 2 September 24th 03 01:01 PM


All times are GMT +1. The time now is 09:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"