By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,979 Members | 951 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,979 IT Pros & Developers. It's quick & easy.

Controlling Excel with Access VBA

P: 1
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:
Expand|Select|Wrap|Line Numbers
  1.     wrkBookName = Application.CurrentProject.Path & "\Delphi Data.xls"
  2.     Set XL = CreateObject("Excel.Application")
  3.     XL.Visible = True
  4.     Set WB = XL.Workbooks.Open(wrkBookName)
  5.     Set ws = WB.Worksheets(1)
  7.     XL.Range("A1:Z38").Replace What:="Invoice", Replacement:="x", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Nov 5 '08 #1
Share this Question
Share on Google+
1 Reply

P: 58
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.
Nov 5 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.