SaveAs without copying Macro

  • Thread starter Thread starter Martijnhj
  • Start date Start date
M

Martijnhj

Hi all,

The very strange things happens. In my VBA code I let the program
delete alle my modules (no problem). At the end of the code i put th
SaveAs function.

This is all no problem (the modules are deleted) , but when I open th
new file (the one that was saved) i get the message: this file contain
macro's. ???? very strange for all modules were deleted. When I chec
the macro, it is the one that i runned before.

Now, the problem is solved when i leave out the DisplayAlerts function
but i don't want to leave this out.

Can anybody help me? If you understand what I mean anyway.

Thanks in advance
 
this is the code

Set VBComp = ThisWorkbook.VBProject.VBComponents_("Module1") - i
i save now (manually) there are no problems

ActiveWorkbook.SaveAs Filename:="C:\temp\file.xls"
FileFormat:=xlNormal,
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
ActiveWorkbook.Close
Application.ScreenUpdating = True
End Sub

when i open file.xls it will display the message enable / disabl
macro's

how is that possible
 
Martijnhj,
Where the code to delete the modules ?

Code behind worksheets also count as macros.

NickHK
 
Hi Nick,

Thanks for your reaction.

this is the code for deleting the module

Set VBComp = ThisWorkbook.VBProject.VBComponents("Module1")
ThisWorkbook.VBProject.VBComponents.Remove VBComp

and then the rest...
 
try windows.close

Sub CloseSelectedWorkbook()
On Error GoTo nn
Application.DisplayAlerts = False
workbookname = ActiveCell.Value
Windows("" & workbookname & ".xls").Close
Range("C3").Select
Application.DisplayAlerts = True
nn:
End Sub
 
Martijnhj,
Not sure, bit is it possble to remove the module from which the "remove
module" code running ?

NickHK
 
Back
Top