Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default VBA Macro to open excel file and replace VBA module with update

I do not know if this is possible but can only ask.
I've got a series of workbooks that have a module which contains UDF's
in a module.
I've since discovered that one of the UDF's wasn't calculating
correctly and had to make a change, since then, I've now got to go
over every workbook that I created with the old UDF and update it.
Was hoping that there is a way to programatically open up each
workbook and replace the existing VBA module with a new one to save
time...
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default VBA Macro to open excel file and replace VBA module with update

On Apr 8, 9:38*am, Forgone wrote:
I do not know if this is possible but can only ask.
I've got a series of workbooks that have a module which contains UDF's
in a module.
I've since discovered that one of the UDF's wasn't calculating
correctly and had to make a change, since then, I've now got to go
over every workbook that I created with the old UDF and update it.
Was hoping that there is a way to programatically open up each
workbook and replace the existing VBA module with a new one to save
time...


Ok... have found a way to delete a VBA module.....

http://www.teachexcel.com/free-excel...acro-free.html

Sub Delete_Module()
Dim vbCom As Object

Set vbCom = Application.VBE.ActiveVBProject.VBComponents

vbCom.Remove VBComponent:= _
vbCom.Item("Module1")

End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default VBA Macro to open excel file and replace VBA module with update

On Apr 8, 9:40*am, Forgone wrote:
On Apr 8, 9:38*am, Forgone wrote:

I do not know if this is possible but can only ask.
I've got a series of workbooks that have a module which contains UDF's
in a module.
I've since discovered that one of the UDF's wasn't calculating
correctly and had to make a change, since then, I've now got to go
over every workbook that I created with the old UDF and update it.
Was hoping that there is a way to programatically open up each
workbook and replace the existing VBA module with a new one to save
time...


Ok... have found a way to delete a VBA module.....

http://www.teachexcel.com/free-excel...e-vba-module-e...

Sub Delete_Module()
Dim vbCom As Object

Set vbCom = Application.VBE.ActiveVBProject.VBComponents

vbCom.Remove VBComponent:= _
vbCom.Item("Module1")

End Sub


Macro to copy a module......

Sub CopyModule(SourceWB As Workbook, strModuleName As String, _
TargetWB As Workbook)
' copies a module from one workbook to another
' example:
' CopyModule Workbooks("Book1.xls"), "Module1", _
Workbooks("Book2.xls")
Dim strFolder As String, strTempFile As String
strFolder = SourceWB.Path
If Len(strFolder) = 0 Then strFolder = CurDir
strFolder = strFolder & "\"
strTempFile = strFolder & "~tmpexport.bas"
On Error Resume Next
SourceWB.VBProject.VBComponents(strModuleName).Exp ort strTempFile
TargetWB.VBProject.VBComponents.Import strTempFile
Kill strTempFile
On Error GoTo 0
End Sub
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default VBA Macro to open excel file and replace VBA module with update

On Apr 8, 9:42*am, Forgone wrote:
On Apr 8, 9:40*am, Forgone wrote:



On Apr 8, 9:38*am, Forgone wrote:


I do not know if this is possible but can only ask.
I've got a series of workbooks that have a module which contains UDF's
in a module.
I've since discovered that one of the UDF's wasn't calculating
correctly and had to make a change, since then, I've now got to go
over every workbook that I created with the old UDF and update it.
Was hoping that there is a way to programatically open up each
workbook and replace the existing VBA module with a new one to save
time...


Ok... have found a way to delete a VBA module.....


http://www.teachexcel.com/free-excel...e-vba-module-e...


Sub Delete_Module()
Dim vbCom As Object


Set vbCom = Application.VBE.ActiveVBProject.VBComponents


vbCom.Remove VBComponent:= _
vbCom.Item("Module1")


End Sub


Macro to copy a module......

Sub CopyModule(SourceWB As Workbook, strModuleName As String, _
* * TargetWB As Workbook)
' copies a module from one workbook to another
' example:
' CopyModule Workbooks("Book1.xls"), "Module1", _
* * Workbooks("Book2.xls")
Dim strFolder As String, strTempFile As String
* * strFolder = SourceWB.Path
* * If Len(strFolder) = 0 Then strFolder = CurDir
* * strFolder = strFolder & "\"
* * strTempFile = strFolder & "~tmpexport.bas"
* * On Error Resume Next
* * SourceWB.VBProject.VBComponents(strModuleName).Exp ort strTempFile
* * TargetWB.VBProject.VBComponents.Import strTempFile
* * Kill strTempFile
* * On Error GoTo 0
End Sub


Never mind...... I found that it was much easier to do it manually by
copying and pasting via the VBA editor as I also had to update the
formulas to include the additional range to look at in each workbook
as well.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Module not file when open the excel file Thomas Excel Discussion (Misc queries) 1 July 14th 07 02:48 PM
Ghost Links which force Excel to update on File Open ExcelMonkey Excel Programming 1 August 15th 05 01:52 PM
Macro to replace a VBA module? mrl[_2_] Excel Programming 3 August 5th 05 09:08 PM
Replace Excel File Open with Windows Explorer KymY Excel Discussion (Misc queries) 2 May 2nd 05 01:05 PM
Automate open file, update links, run macro, close and save file Geoff[_7_] Excel Programming 2 August 26th 03 10:13 PM


All times are GMT +1. The time now is 08:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"