copying a module

cbennetts

New Member
Joined
Feb 23, 2004
Messages
29
Good Day all.
Here is the deal, I have a workbook which is called HM2005Nov23 that does automatic queries to the net every second. That runs just fine. When I get an error though (ie 1004) I want it to clone itself (modules and all) into another book that is titled the same but with a .1, .2, .3 etc. depending on how many times it has had to clone itself. After it clones itself I want it to delete the old version of itself and then start the web query again. Any suggestions?

Chet
 

Some videos you may like

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Oorang

Well-known Member
Joined
Mar 4, 2005
Messages
2,071
Just use thisworkbook.saveas
Then delete the old file with Kill
 

cbennetts

New Member
Joined
Feb 23, 2004
Messages
29
By using the aforementioned kill, will that completly delete the old file?
 

cbennetts

New Member
Joined
Feb 23, 2004
Messages
29

ADVERTISEMENT

Sounds like exactly what I want to do. Would it look something like this:

Sub kill()
'
'Other applicable code
'
Workbooks("try to kill").kill
'
'Other applicable code
'
End Sub
 

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,453
If you're using SaveAs to create a new copy of the workbook, the module will get saved in the new workbook also. There shouldn't be a need for exporting/importing the module itself.

BTW, I didn't ignore your PM. When I tried using the relevent code to export/import Module1 between a couple workbooks, Norton freaked out. Said I had a Bloodhound virus named "ExcelMacro". Had a bit of a time getting rid of those two workbooks.
(Now Norton is happy again.)
 

cbennetts

New Member
Joined
Feb 23, 2004
Messages
29
That is the same problem I had too. Interesting. I will try the save as instead. Thanks and Happy Turkey Day!

Chet
 

Watch MrExcel Video

Forum statistics

Threads
1,118,448
Messages
5,572,174
Members
412,447
Latest member
immy
Top