compile error type mismatch

  • Thread starter Thread starter I.M. Shatner
  • Start date Start date
I

I.M. Shatner

I'm having trouble getting this macro to run in Excel. It stops at the line
in between the arrows, telling me "Complie Error: Type Mismatch". I'm a
complete novice at this so please help!


Sub BOM()
'
Dim myobject As Object
Dim object As String
Set oApp = myobject
oApp.Visible = True

oApp.cells.select

With selection.Font
.Size = 9
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = 1
End With
oApp.selection.Rows.AutoFit
oApp.selection.Columns("A:A").select
oApp.selection.Font.Bold = True
oApp.selection.Range("A1").select
End Sub
 
Wrong forum. THis is an Access (database application) forum

However, it appears to me that the line should read

myobject = "C:\dir\folder\filename"

Note the lack of SET since you are working with a string. As for the
remainder of the code, check in an Excel forum

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 
I would think that the declaration should also be changed to

Dim myobject As String
 
When I change the declaration I get a runtime 91 "Object variable or With
object variable not set".
 
Have you declared oApp anywhere?

Actually, I think you may need to use

Dim oApp As Object

and

Set oApp = GetObject(Myobject)
 
Joel at the Excel board suggested I use this code. But with this I get held
up at Set oApp with a runtime 432 error.
 
Error 432 is "File name or class name not found during Automation
operation".

Your sample code doesn't have an xls file extension for FName. Does your
actual code have one?

If it does, does the file actually exist?
 
The .xls was the culprit. Thanks for the help.

Douglas J. Steele said:
Error 432 is "File name or class name not found during Automation
operation".

Your sample code doesn't have an xls file extension for FName. Does your
actual code have one?

If it does, does the file actually exist?
 
Back
Top