Remove/Delete Macro

F

FredrikT

Hi,

I have a ppt-file in which the data is populated by a
macro. When the data is populated and the file is saved
(or other event), I want to delete the macro so that the
file no longer contains the macro, preventing the user
from populating the file with data again?

Is it possible to delete/remove the macro from the file
programatically?
 
C

Charles Maxson

Fredrik,

While it is possible, it is frowned upon (i.e. how viruses get there start).
A better practice would be where your macro manages/checks a varaible
setting to see if it has run before and do not allow it to completly run if
the variable indicates it has been ran. Also you can have the macro remove
its own UI after initial use e.g. delete the menu, toolbar or command button
it uses.

Running code against code always has tighter security restrictions (not
tight enuff in VBA though) where you need to manage settings/signatures that
make it harder than it is worth.
 
E

Ed White

Why not just have your macro save your data to a new file
(different from the one in which the macro is running?)

Alternatively, after your macro populates the data in the
current file, it could copy the data to a new file
without the macro and save that file.

Ed
 
F

FredrikT

-----Ursprungligt meddelande-----
Why not just have your macro save your data to a new file
(different from the one in which the macro is running?)

This is exactly what I want to do! But when I do it like
this:

Application.ActivePresentation.SaveAs ("d:\temp\new")

the macro is still in the new file. How do I remove it? Is
there a method like .SaveWithoutMacroAs?

My macro is in a module.
 
F

FredrikT

Ok, I guess you could use a variable check to prevent it
from running again.

The macro is all automatic in the background, it is never
triggered explicitly by the user. So the user can only run
the macro again by using the Tools > Macro menu. In most
cases the users wont do that, I guess most of them dont
even know what a macro is. But I still think it would be
good if the saved file would be clean from all macros
 
E

Ed White

I'm suggesting that your macro should be in one Excel
file (i.e. workbook), and the data in another. From one
workbook, you can open or create a second, different
workbook and manipulate its contents. Then, once you are
done with the second workbook, save it. This way, the
workbook with the data would never include the macro. Do
you know how to do this?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top