View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Phil Hibbs Phil Hibbs is offline
external usenet poster
 
Posts: 100
Default Updating the VBA code in multiple spreadsheets

I'm now trying to port this to Excel, and I'm hitting a problem where
the Remove method fails with "Object doesn't support this method or
property":

Sub UpdateVBA()
Dim oExcel As Application
Dim oComponent As Object

Set oExcel = New Excel.Application
Set oBook = oExcel.Workbooks.Open("C:\Test.xls", 0, False, , , ,
True)
Set oComponent = oBook.VBProject.VBComponents("TestModule")
oBook.VBProject.VBComponents.Remove (oComponent) ' <== FAIL
oBook.VBProject.VBComponents.Import ("C:\TestModule.txt")
oBook.VBProject.VBComponents
(oBook.VBProject.VBComponents.Count).Name = "TestModule"
oBook.Close
oExcel.Quit

End Sub

Any ideas?

Phil Hibbs.