Help please....

P

Phillips

I have the following code and I get the following error"
Object variable or With block variable not set (Error 91) on the line:
Set c = xlApp.Worksheets("master").Find("555)111-2222", LookIn:=xlValues)

What is going one?
I am calling this from OUTLOOK.

Here is my code:

Private Function WorkbookIsOpen1(wbname) As Boolean 'wbname will be passed
once I get te resr working...

Dim tempx As Object
Dim c As Range
Dim b As Range
Dim xlSheet As Excel.Worksheet

MsgBox " WorkbookIsOpen1"

Set tempx = GetObject("C:\current.xls")
MsgBox " WorkbookIsOpen1: " & Err

If Err = 0 Then
WorkbookIsOpen1 = True
MsgBox "WorkbookIsOpen: " & WorkbookIsOpen1
tempx.Worksheets("master").Activate
Set c = xlApp.Worksheets("master").Find("(555)111-2222",
LookIn:=xlValues)
If Not c Is Nothing Then
MsgBox c.Offset(0, -3)
Else
MsgBox "Not found..."
End If
Else
WorkbookIsOpen1 = False
MsgBox "error: " & Err
MsgBox "WorkbookIsOpen: " & WorkbookIsOpen1
End If


End Function


Thanks
 
P

Patrick Molloy

change these
tempx.Worksheets("master").Activate
Set c = xlApp.Worksheets("master").Find("(555)111- 2222",
LookIn:=xlValues)

to

SET xlSheet = tempx.Worksheets("master")
Set c = xlSheet.Cells..Find("(555)111-2222", _
LookIn:=xlValues)

Patrick Molloy
Microsoft Excel MVP
 
T

Tom Ogilvy

Set c = xlSheet.Cells..Find("(555)111-2222", _
LookIn:=xlValues)

should only have one full stop/period between cells and find

Set c = xlSheet.Cells.Find("(555)111-2222", _
LookIn:=xlValues)
 

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