ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Use VBA (Macro) to Update Existing Macro (https://www.excelbanter.com/excel-programming/383029-use-vba-macro-update-existing-macro.html)

Jordan Marton

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


Tom Ogilvy

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



Jordan Marton

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 -




Tom Ogilvy

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 -





Jordan Marton

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 -




Tom Ogilvy

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 -






Jordan Marton

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!



All times are GMT +1. The time now is 12:26 PM.

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