VBA Error Code Type Mismatch

cvincent

Board Regular
Joined
Aug 28, 2011
Messages
66
The following runs fine, however my Excel file is displaying Run-time error 13: Type mismatch. Not sure what that means. Can someone please tell me how to correct this? Thank you.


Sub OpenWordDoc()

Application.DisplayAlerts = False
Dim wordApp As Object
Dim wordDoc As Object
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.documents.Open("F:\EMERGENCY CONTACT MERGE DOC (6-2013).docm", ReadOnly:=True)

Application.DisplayAlerts = True
End Sub
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
cvincent,

You have different strings declaring the object variables compared to when you are setting them!!

Hope that helps.
 
Upvote 0
cvincent,

You have different strings declaring the object variables compared to when you are setting them!!

Hope that helps.

Thank you for taking the time to look at this. I am not very familiar with object variables, and no on-site support. Thank goodness for Mr. Excel! This will help me correct it.
 
Upvote 0
Did you get it corrected cvincent? He's referring to you having declared the variables as WordApp and WordDoc but set them as wrdApp and wrdDoc.
 
Upvote 0
Did you get it corrected cvincent? He's referring to you having declared the variables as WordApp and WordDoc but set them as wrdApp and wrdDoc.

Yes, thank you devlynsyde, I did. I saw the differences corrected it, then changed it up a bit.
 
Upvote 0

Forum statistics

Threads
1,215,767
Messages
6,126,767
Members
449,336
Latest member
p17tootie

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