ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   SaveAs without copying Macro (https://www.excelbanter.com/excel-programming/292626-saveas-without-copying-macro.html)

Martijnhj

SaveAs without copying Macro
 
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

--
Message posted from http://www.ExcelForum.com


Martijnhj[_2_]

SaveAs without copying Macro
 
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

--
Message posted from http://www.ExcelForum.com


Nick Cranham

SaveAs without copying Macro
 
Martijnhj,
Where the code to delete the modules ?

Code behind worksheets also count as macros.

NickHK

"Martijnhj " wrote in message
...
this is the code

Set VBComp = ThisWorkbook.VBProject.VBComponents_("Module1") - if
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 / disable
macro's

how is that possible?


---
Message posted from http://www.ExcelForum.com/




Martijnhj[_3_]

SaveAs without copying Macro
 
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...

--
Message posted from http://www.ExcelForum.com


Don Guillett[_4_]

SaveAs without copying Macro
 
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

--
Don Guillett
SalesAid Software

"Martijnhj " wrote in message
...
this is the code

Set VBComp = ThisWorkbook.VBProject.VBComponents_("Module1") - if
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 / disable
macro's

how is that possible?


---
Message posted from
http://www.ExcelForum.com/




Nick Cranham

SaveAs without copying Macro
 
Martijnhj,
Not sure, bit is it possble to remove the module from which the "remove
module" code running ?

NickHK

"Martijnhj " wrote in message
...
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....


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 12:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com