Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Use VBA (Macro) to Update Existing Macro
Hi.
I have about 100 files that have the same embedded macro in them. I need to update one of the functions that is contained in the macro code. I know how to loop through all the files, open each one, and save/ close them. What I don't know how to do is modify the embedded macro functions. Can someone please tell me how I can replace a function with a new one automatically so I don't have to open the code editor for each one. Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Use VBA (Macro) to Update Existing Macro
http://www.cpearson.com/excel/vbe.htm
should give you the ins and outs of writing code to manipulate code. Hopefully your projects are not protected in any of the workbooks. -- Regards, Tom Ogilvy "Jordan Marton" wrote: Hi. I have about 100 files that have the same embedded macro in them. I need to update one of the functions that is contained in the macro code. I know how to loop through all the files, open each one, and save/ close them. What I don't know how to do is modify the embedded macro functions. Can someone please tell me how I can replace a function with a new one automatically so I don't have to open the code editor for each one. Thanks |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Use VBA (Macro) to Update Existing Macro
I have seen that site. I tried the following code:
Sub CopyModule() Dim FName As String With Workbooks("MasterBook") FName = .Path & "\code.txt" .VBProject.VBComponents("Module1").Export FName End With Workbooks("OldFile").VBProject.VBComponents.Import FName End Sub Figured I could export then import into the new excel file. Problem is, my virus program keeps blocking me from saving this code, says it is a Bloodhound virus or something. I am on a corporate network and turning the virus checker off is not an option. Any other ideas? On Feb 12, 9:36 am, Tom Ogilvy wrote: http://www.cpearson.com/excel/vbe.htm should give you the ins and outs of writing code to manipulate code. Hopefully your projects are not protected in any of the workbooks. -- Regards, Tom Ogilvy "Jordan Marton" wrote: Hi. I have about 100 files that have the same embedded macro in them. I need to update one of the functions that is contained in the macro code. I know how to loop through all the files, open each one, and save/ close them. What I don't know how to do is modify the embedded macro functions. Can someone please tell me how I can replace a function with a new one automatically so I don't have to open the code editor for each one. Thanks- Hide quoted text - - Show quoted text - |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Use VBA (Macro) to Update Existing Macro
exporting a module does not remove the module. You would need to delete it
before importing a new one. http://tinyurl.com/33edbs has a list of articles discussing the bloodhound virus problem. -- Regards, Tom Ogilvy "Jordan Marton" wrote: I have seen that site. I tried the following code: Sub CopyModule() Dim FName As String With Workbooks("MasterBook") FName = .Path & "\code.txt" .VBProject.VBComponents("Module1").Export FName End With Workbooks("OldFile").VBProject.VBComponents.Import FName End Sub Figured I could export then import into the new excel file. Problem is, my virus program keeps blocking me from saving this code, says it is a Bloodhound virus or something. I am on a corporate network and turning the virus checker off is not an option. Any other ideas? On Feb 12, 9:36 am, Tom Ogilvy wrote: http://www.cpearson.com/excel/vbe.htm should give you the ins and outs of writing code to manipulate code. Hopefully your projects are not protected in any of the workbooks. -- Regards, Tom Ogilvy "Jordan Marton" wrote: Hi. I have about 100 files that have the same embedded macro in them. I need to update one of the functions that is contained in the macro code. I know how to loop through all the files, open each one, and save/ close them. What I don't know how to do is modify the embedded macro functions. Can someone please tell me how I can replace a function with a new one automatically so I don't have to open the code editor for each one. Thanks- Hide quoted text - - Show quoted text - |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Use VBA (Macro) to Update Existing Macro
So I checked out the link you sent and found one of the sites that
provides a workaround. So far so good. One more question. Several of my files have password protected macro code (you have to type the password in the editor to see it). Any way around that? On Feb 12, 10:25 am, Tom Ogilvy wrote: exporting a module does not remove the module. You would need to delete it before importing a new one. http://tinyurl.com/33edbs has a list of articles discussing the bloodhound virus problem. -- Regards, Tom Ogilvy "Jordan Marton" wrote: I have seen that site. I tried the following code: Sub CopyModule() Dim FName As String With Workbooks("MasterBook") FName = .Path & "\code.txt" .VBProject.VBComponents("Module1").Export FName End With Workbooks("OldFile").VBProject.VBComponents.Import FName End Sub Figured I could export then import into the new excel file. Problem is, my virus program keeps blocking me from saving this code, says it is a Bloodhound virus or something. I am on a corporate network and turning the virus checker off is not an option. Any other ideas? On Feb 12, 9:36 am, Tom Ogilvy wrote: http://www.cpearson.com/excel/vbe.htm should give you the ins and outs of writing code to manipulate code. Hopefully your projects are not protected in any of the workbooks. -- Regards, Tom Ogilvy "Jordan Marton" wrote: Hi. I have about 100 files that have the same embedded macro in them. I need to update one of the functions that is contained in the macro code. I know how to loop through all the files, open each one, and save/ close them. What I don't know how to do is modify the embedded macro functions. Can someone please tell me how I can replace a function with a new one automatically so I don't have to open the code editor for each one. Thanks- Hide quoted text - - Show quoted text -- Hide quoted text - - Show quoted text - |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Use VBA (Macro) to Update Existing Macro
No provision for opening a password protected project using code. Only
suggestions I have seen involve using sendkeys. -- Regards, Tom Ogilvy "Jordan Marton" wrote in message oups.com... So I checked out the link you sent and found one of the sites that provides a workaround. So far so good. One more question. Several of my files have password protected macro code (you have to type the password in the editor to see it). Any way around that? On Feb 12, 10:25 am, Tom Ogilvy wrote: exporting a module does not remove the module. You would need to delete it before importing a new one. http://tinyurl.com/33edbs has a list of articles discussing the bloodhound virus problem. -- Regards, Tom Ogilvy "Jordan Marton" wrote: I have seen that site. I tried the following code: Sub CopyModule() Dim FName As String With Workbooks("MasterBook") FName = .Path & "\code.txt" .VBProject.VBComponents("Module1").Export FName End With Workbooks("OldFile").VBProject.VBComponents.Import FName End Sub Figured I could export then import into the new excel file. Problem is, my virus program keeps blocking me from saving this code, says it is a Bloodhound virus or something. I am on a corporate network and turning the virus checker off is not an option. Any other ideas? On Feb 12, 9:36 am, Tom Ogilvy wrote: http://www.cpearson.com/excel/vbe.htm should give you the ins and outs of writing code to manipulate code. Hopefully your projects are not protected in any of the workbooks. -- Regards, Tom Ogilvy "Jordan Marton" wrote: Hi. I have about 100 files that have the same embedded macro in them. I need to update one of the functions that is contained in the macro code. I know how to loop through all the files, open each one, and save/ close them. What I don't know how to do is modify the embedded macro functions. Can someone please tell me how I can replace a function with a new one automatically so I don't have to open the code editor for each one. Thanks- Hide quoted text - - Show quoted text -- Hide quoted text - - Show quoted text - |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Use VBA (Macro) to Update Existing Macro
On Feb 13, 12:30 pm, "Tom Ogilvy" wrote:
No provision for opening a password protected project using code. Only suggestions I have seen involve using sendkeys. -- Regards, Tom Ogilvy "Jordan Marton" wrote in message oups.com... So I checked out the link you sent and found one of the sites that provides a workaround. So far so good. One more question. Several of my files have password protected macro code (you have to type the password in the editor to see it). Any way around that? On Feb 12, 10:25 am, Tom Ogilvy wrote: exporting a module does not remove the module. You would need to delete it before importing a new one. http://tinyurl.com/33edbs has a list of articles discussing the bloodhound virus problem. -- Regards, Tom Ogilvy "Jordan Marton" wrote: I have seen that site. I tried the following code: Sub CopyModule() Dim FName As String With Workbooks("MasterBook") FName = .Path & "\code.txt" .VBProject.VBComponents("Module1").Export FName End With Workbooks("OldFile").VBProject.VBComponents.Import FName End Sub Figured I could export then import into the new excel file. Problem is, my virus program keeps blocking me from saving this code, says it is a Bloodhound virus or something. I am on a corporate network and turning the virus checker off is not an option. Any other ideas? On Feb 12, 9:36 am, Tom Ogilvy wrote: http://www.cpearson.com/excel/vbe.htm should give you the ins and outs of writing code to manipulate code. Hopefully your projects are not protected in any of the workbooks. -- Regards, Tom Ogilvy "Jordan Marton" wrote: Hi. I have about 100 files that have the same embedded macro in them. I need to update one of the functions that is contained in the macro code. I know how to loop through all the files, open each one, and save/ close them. What I don't know how to do is modify the embedded macro functions. Can someone please tell me how I can replace a function with a new one automatically so I don't have to open the code editor for each one. Thanks- Hide quoted text - - Show quoted text -- Hide quoted text - - Show quoted text -- Hide quoted text - - Show quoted text - I was able to sucessfully implement SendKeys. My process now loops through a folder of Excel files. Opens each one, makes sheet changes. Unprotects the VBA code using send keys. Uses a delete procedure to remove an old function. Then uses code to import a new module (containing the updated function). Saves, closes, and uploads to SharePoint. SendKeys was a pain to implement but I found good code online. And I got a workaround for the importing a new module so no more virus alerts. Thanks for all the help! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
need help to update macro to office 2007 macro enabled workbook | Excel Discussion (Misc queries) | |||
Use existing macro to create another macro | Excel Programming | |||
Recording a macro within existing macro. | Excel Programming | |||
Macro Help - check existing tabs | Excel Programming | |||
Change to existing macro | Excel Programming |