View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] preedy@mayinstitute.org is offline
external usenet poster
 
Posts: 1
Default modifying code using addfromfile method

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.