A
Amedee Van Gasse
I'm sorry about the cross-post, I don't know which group is best for this
question.
I have encountered a problem with an Excel/VBA application I'm developing.
One of the things I do is creating sheets on the fly using VBA, like this:
Wb.Sheets.Add After:=Worksheets(Worksheets.Count)
Then I add event procedures to this sheet, following an example on Chip
Pearson's site: http://www.cpearson.com/excel/vbe.htm - Creating An Event
Procedure.
Dim StartLine As Long
Dim Code As String
Code = "Msgbox ""Hello World"",vbOkOnly"
With ActiveWorkbook.VBProject.VBComponents(Sh.CodeName).CodeModule
StartLine = .CreateEventProc("Activate", "Worksheet") + 1
.InsertLines StartLine, Code
End With
This works just fine as long as I don't close the file.
When I save, close and re-open the file again, there are two possible
situations:
- either the project was digitally signed, then I get a message that the
file was infected by a virus and that macros are disabled. I have checked
all code extensively but found no virus at all.
- or the project was not signed. In that case I get the usual security
warning and question about enabling/disabling macros.
After that, the result is always the same: the code module that contained
the VBComponents code, is completely wiped!
McAfee is installed on this machine and I suspect it has something to do
with this problem.
Does anyone know a workaround?
--
Amedee Van Gasse
To top-post is human, to bottom-post and snip is sublime.
Dit bericht is geplaatst in een nieuwsgroep. Post je evt antwoord of
vervolgvraag graag in dezelfde thread in de nieuwsgroep a.u.b.
question.
I have encountered a problem with an Excel/VBA application I'm developing.
One of the things I do is creating sheets on the fly using VBA, like this:
Wb.Sheets.Add After:=Worksheets(Worksheets.Count)
Then I add event procedures to this sheet, following an example on Chip
Pearson's site: http://www.cpearson.com/excel/vbe.htm - Creating An Event
Procedure.
Dim StartLine As Long
Dim Code As String
Code = "Msgbox ""Hello World"",vbOkOnly"
With ActiveWorkbook.VBProject.VBComponents(Sh.CodeName).CodeModule
StartLine = .CreateEventProc("Activate", "Worksheet") + 1
.InsertLines StartLine, Code
End With
This works just fine as long as I don't close the file.
When I save, close and re-open the file again, there are two possible
situations:
- either the project was digitally signed, then I get a message that the
file was infected by a virus and that macros are disabled. I have checked
all code extensively but found no virus at all.
- or the project was not signed. In that case I get the usual security
warning and question about enabling/disabling macros.
After that, the result is always the same: the code module that contained
the VBComponents code, is completely wiped!
McAfee is installed on this machine and I suspect it has something to do
with this problem.
Does anyone know a workaround?
--
Amedee Van Gasse
To top-post is human, to bottom-post and snip is sublime.
Dit bericht is geplaatst in een nieuwsgroep. Post je evt antwoord of
vervolgvraag graag in dezelfde thread in de nieuwsgroep a.u.b.