[VBA] Error 438 when trying to open an existing Workbook

SDempster

New Member
Joined
Jan 14, 2015
Messages
6
Hey all.

I am having a weird error. In my function I am opening an existing Workbook, using Find method to locate a search criteria and store its row, and using the row to find a String in "E<ROW>". This works fine on one computer in another code which I used to trouble shoot it, but when I implement the same exact code on my other computer in a different script I am running into "Error 438: Object doesn't support this property or method" right before it attempts to open the Workbook. I looked at both References on both computers and there are no differences besides the bugged computer using 'OLE Automation'. Here's the Function's code. The error happens on the 4th line.

Function findAssEgr(enNum As String) As String 'find the assigned engineer
Dim Log As Workbook
Application.EnableEvents = False
Set Log = Workbooks.Open("<LOCATION>, Test.xlsm", True, True) 'Error occurs right before this line, but doesn't highlight this
Application.EnableEvents = True

Dim rngSearch As Range, rngFound As Range
Set rngSearch = Log.Sheets("EN Log").Range("A:A")
Set rngFound = rngSearch.Find(What:=enNum, LookIn:=xlValues, LookAt:=xlPart) 'Search for the criteria's location in the test log

findAssEgr = Log.Worksheets("EN Log").Cells(rngFound.Row, 5) 'Assigned Engineer's name

Log.Close False

End Function

Another thing to note is that if I exclude the Application.EnableEvents on line 3 I get "Automation Error, Library not registered" at the same location.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Do you have ActiveX controls on worksheets in this workbook?
 
Upvote 0
I'm new to VBA so I'm not positive, but I do know that some other projects on this machine use ADODB and I do have the option to include the MS ActiveX Data Objects 6.1 Library. Or is there another way to find out?

edit: never mind, found out I do have ActiveX controls in Excel.
 
Last edited:
Upvote 0
Does the current workbook work on the other computer?

My suspicion is that you have run into the ActiveX problem caused by the MS updates released in December (see the banner at the top of the forum).

I should mention that the file name here looks weird to me:

Rich (BB code):
Set Log = Workbooks.Open(", Test.xlsm", True, True)
but I wouldn't expect a 438 error from it.

One last thing, do you have any references set in this project to other applications? (eg Word, Outlook)
 
Upvote 0
ActiveX: I'll look into it, but by the looks of it this script isn't using ActiveX controls.

File name: That was a mistake. I changed the name of the file for this post for security reasons. It's inputted correctly in the actual code.

References: Yes, I am also Referenced to Microsoft Outlook 14.0 Data Library as this script deals with emails. The machine which correctly runs the function does not use the Outlook reference (my mistake for saying it did. I overlooked it). But when I enable that reference it still works.
 
Last edited:
Upvote 0
Does the Outlook reference appear above the Excel one in the references list? (very unlikely, but I've seen some strange things!)

If there are activeX controls on a sheet in the workbook anywhere, they can cause this problem, even if they are unrelated to the script in question.

One other thing to check - is there any code in the Open event of the workbook being opened?
 
Upvote 0
Outlook Reference: Yes, it is above the Excel reference.

New Workbook Code: Yes, there is code. It doesn't seem to be a problem on the other machine though.
 
Upvote 0
That's very odd - assuming this code is in Excel, not Outlook?
 
Upvote 0
Nope, I believe it's in Outlook. Then I will add that the working machine was using an Excel VBA and the bugged machine is using Outlook VBA.
 
Last edited:
Upvote 0
Oh. In that case it needs to be completely rewritten:

Code:
Function findAssEgr(enNum As String) As String 'find the assigned engineer
Dim appXL As Excel.Application
Dim rngSearch As Excel.Range, rngFound As Excel.Range
Dim Log As Excel.Workbook

Set appXL = CreateObject("Excel.Application")
appXL.EnableEvents = False
Set Log = appXL.Workbooks.Open(", Test.xlsm", True, True) 'Error occurs right before this line, but doesn't highlight this
Application.EnableEvents = True

Set rngSearch = Log.Sheets("EN Log").Range("A:A")
Set rngFound = rngSearch.Find(What:=enNum, LookIn:=xlValues, LookAt:=xlPart) 'Search for the criteria's location in the test log

If Not rngFound Is Nothing Then findAssEgr = Log.Worksheets("EN Log").Cells(rngFound.Row, 5) 'Assigned Engineer's name

Log.Close False
appXL.Quit

End Function
for example.
 
Upvote 0

Forum statistics

Threads
1,216,246
Messages
6,129,700
Members
449,528
Latest member
Paula03

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top