Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am writing a macro which corrects code in many standard workbooks. I
have a loop which deletes all the code from a module and then adds the corrected code from a file using the addfromfile method. The loop works correctly with the first workbook but not any subsequent workbooks. Why does the addfromfile method only work once? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Paul,
As ever, your code would help. -- HTH RP (remove nothere from the email address if mailing direct) "PaulR" wrote in message om... I am writing a macro which corrects code in many standard workbooks. I have a loop which deletes all the code from a module and then adds the corrected code from a file using the addfromfile method. The loop works correctly with the first workbook but not any subsequent workbooks. Why does the addfromfile method only work once? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This is the routine which swaps the code:
Sub MSmodMender() 'replaces code in a module with code from a text file For Each i In Application.VBE.VBProjects("VBAMidasWrkShtProj").V BComponents If i.codemodule.Name = "UpdatePhaseMod" Then 'need to name the module to be replaced i.codemodule.DeleteLines 1, i.codemodule.CountOfLines 'delete all lines in the module i.codemodule.AddFromFile "cape cod:fmidas:closet:back shelf:UpdatePhases03042005.txt" 'need to name the text file Exit Sub End If Next End Sub It works fine on the first workbook I loop to, but on all subsequent loops only the DeleteLines method statement works. The statement with AddfromFile method does nothing, not even an error. Thanks for any help you can offer. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
modifying formulas with code | Excel Programming | |||
Modifying formulas through code | Excel Programming | |||
Need Help Modifying Code | Excel Programming | |||
Help modifying code | Excel Programming | |||
Modifying Code that deletes a Row | Excel Programming |