compile error type mismatch

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
 
J

John Spencer

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
 
D

Douglas J. Steele

I would think that the declaration should also be changed to

Dim myobject As String
 
I

I.M. Shatner

When I change the declaration I get a runtime 91 "Object variable or With
object variable not set".
 
D

Douglas J. Steele

Have you declared oApp anywhere?

Actually, I think you may need to use

Dim oApp As Object

and

Set oApp = GetObject(Myobject)
 
I

I.M. Shatner

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.
 
D

Douglas J. Steele

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?
 
I

I.M. Shatner

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?
 

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