Insert VBA code with a macro in a .xls file by workbook open event

M

mihai

I have a macro that creates an .xls file every time it runs. I want th
macro to insert code in the new file by workbook open and before clos
event. The result should be that the new file executes some operatio
on open and close
 
A

Amedee Van Gasse

Bob said:
Take a look at www.cpearson.com/excel/vbe.htm. This page shows you
how to dynamically add code.

And uninstall any virus scanners like McAfee. They are very efficient
at wiping your entire code module if you dare to use the methods
described in the quoted link.
I learned that the hard way.
 
B

Bob Phillips

If that is true, and I must admit I have never experienced it with AVG, then
I would suggest that a different approach is taken. Uninstalling virus
scanners is a bit too drastic for me.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
M

mihai

Thanks for the help.
I found the answer for my question on that page. I found a lot of othe
interesting thinks there.
About the antivirus, I have NAV I will see what happens
 
K

keepITcool

I partly agree with Amedee.

You have to TEST that McAfee will not see your legitimate code
as a virus. McAfee has a routine for 1 of the first macro virii
that aggressively wipes any code from ThisWorkbook that modifies
the VBproject.

But you CAN prevent being seen as a virus..
takes careful testing and the procedure to modify the VBproject must be
moved from ThisWorkbook module to a normal module.



--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Amedee Van Gasse wrote :
 
A

Amedee Van Gasse

keepITcool said:
I partly agree with Amedee.

You have to TEST that McAfee will not see your legitimate code
as a virus. McAfee has a routine for 1 of the first macro virii
that aggressively wipes any code from ThisWorkbook that modifies
the VBproject.

But you CAN prevent being seen as a virus..
takes careful testing and the procedure to modify the VBproject must
be moved from ThisWorkbook module to a normal module.

Keep,

Been there, done that, and you know it from following

My code was in a normal module, and it was just called from an event
handler in ThisWorkbook. The normal module was still wiped.

Perhaps it also depends on the specific McAfee product. The "desktop"
product for end-users might work different compared to the "network"
product for companies.
 
K

keepITcool

Amai.. Amedee!

send me one that gets wiped..
and i'll try to build it so it wont get wiped.

bottle of Lagavullin?


Amedee Van Gasse wrote :
 
Top