calling original excel code from access

J

jonefer

I've added the following line

Dim xlapp as Excel.Applicatio
Set xlApp = CreateObject("Excel.Application"

to make a macro I wrote in Excel now work from Access - (and eventually VB6

it seems the only code that will no longer work is

xlApp.Cells.Find(What:="UHA Risk", After:=ActiveCell, LookIn:=xlFormulas,
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False).Activat

Does anyone know how to fix this?
 
K

Ken Snell

As I recall, Cells is an collection belonging to the Worksheet object, which
is a member of the Worksheets collection, which is a collection belonging to
the Workbook object, which is a member of the Workbooks collection, which is
a member of the Application object.

Thus, I believe you need to insert a workbook object reference and a
worksheet object reference in the code for things to work correctly (just a
guess, as I have not used the Find code in EXCEL VBA previously).

Assuming that your syntax for this method is correct,

xlApp.WorkbookObjeceVariableName.WorksheetObjectVariableName.Cells.Find(What
:="UHA Risk", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False).Activate
 
J

Jamie Collins

...
As I recall, Cells is an collection belonging to the Worksheet object, which
is a member of the Worksheets collection, which is a collection belonging to
the Workbook object, which is a member of the Workbooks collection, which is
a member of the Application object.

It could be the implicit ActiveSheet object that's needed i.e.

xlApp.ActiveSheet.Cells.Find(<snip>).Activate

Jamie.

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top