Controlling Excel with Access VBA

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rweston
    New Member
    • Nov 2008
    • 1

    Controlling Excel with Access VBA

    I am trying to open an MS Excel file and perform a find/replace function, all using VBA within MS Access. I keep getting a "Subscript out of range." error. Do you know why I am getting this error? The code I am using is below:
    [CODE=VB]
    wrkBookName = Application.Cur rentProject.Pat h & "\Delphi Data.xls"
    Set XL = CreateObject("E xcel.Applicatio n")
    XL.Visible = True
    Set WB = XL.Workbooks.Op en(wrkBookName)
    Set ws = WB.Worksheets(1 )

    XL.Range("A1:Z3 8").Replace What:="Invoice" , Replacement:="x ", LookAt:=xlPart, SearchOrder:=xl ByRows, MatchCase:=Fals e, SearchFormat:=F alse, ReplaceFormat:= False

    [/CODE]
    Last edited by Dököll; Nov 9 '08, 08:03 PM. Reason: code tags
  • ubentook
    New Member
    • Dec 2007
    • 58

    #2
    What line causes the error?
    What version of Excel are you using?
    '--
    In the meantime, replace the xlConstants with their numeric value. Access does not know what they are.

    Comment

    Working...