run-time error 13 - Type mismatch (don't know why)



  • 1. Option Buttons appear enclosed by a square box on printing
    I'm using Microsoft Word 2003 SP1 on Windows XP Pro. I'm putting Option Buttons in a word doc from the Control Toolbox. Everything works fine and it looks fine on screen. But when I print to a Tektronix Phaser 850DX or to a HP LaserJet 5000 Series PS, the circular option button is surrounded by a filled black square. It looks like an inverse bullet. I'm using the default BackColor = white and BackStyle = opaque and I can't fix the problem by changing these. Has anyone seen that? Thanks
  • 2. How to italicize a word without selecting it, cursor w/in word on.
    In Word, I used to be able to put the cursor within a word like this: anno|ying, and then click control-B, or control-I, or control-U to bold, italicize or underline the entire word. Then my computer crashed and I had to reinstall Word. Now I must highlight/select the entire word to change its attributes. How do I set Word to do like it did before?
  • 3. altering field codes
    can anyone tell me if it is possible to alter field codes with vba. i hav a document which has a picture inserted in the first page and the header of everysubsequent page and the field code for it is as follows. {INCLUDEPICTURE "C:\\Program Files\\Microsoft Office\\Clipart\\WYP\\SIMPLAND.TIF" \* MERGEFORMAT \d } depending on a user selection this picture may change from simpland.tiff to kmc.tiff. is there a way of just changing the field without having to completely reinstall the picture each time or is it best jsut to reinstall the picture. I can code for the reinsert so thats not a problem just wanted to know if the field code could be altered. cheers fred
  • 4. check box that triggers macro
    Hi again, How does one get a check box created by the control toolbox to trigger a one condition when checked and another when not checked? For far I have found that Sub CheckBox1_Click() can be used to trigger an event. But this triggers the same event whether checking or unchecking. What is the if statement that captures the checked and unchecked values for this box?
  • 5. In Forms, want to use "Enter" to advance to next field instead of
    Typically, when filling out forms, "enter" is used to complete the entry and advance to the next field. In Word 2002, although the document is protected, hitting "enter" just inserts a paragraph return outside of the field, which messes up the Form's format. How do I get "Enter" to only advance to the next field once the document is locked? I am using the "Forms" tool bar. Thanks!

run-time error 13 - Type mismatch (don't know why)

Postby anVzdGFsb3N0Z3J1bnQ » Thu, 08 Nov 2007 06:54:01 GMT


What worked six months ago seems to give a runtime error now.
Revisting a VBA routine as the project has come out of moth balls.

error 13 - type mismatch on the line:

Set bmrange = destdoc11.Bookmarks("section11").Range ' locate the bookmark

In the snippet of the whole routine,

If Dir(strAtt) = "" Then
MsgBox "File does not exist"
Set srcDoc = Wordapp.Documents.Open(strAtt) 'attachment sheet
End If

'open the letter
Set destdoc11 = Wordapp.Documents.Open(strInputFileName) 'letter

Set bmrange = destdoc11.Bookmarks("section11").Range ' locate the bookmark

'create new section - add a page past the bookmark

're-insert the bookmark as we have removed it by the section break
destdoc11.Bookmarks.Add "section11", bmrange
'copy the text and replace the bookmark
bmrange.FormattedText = srcDoc.Range.FormattedText
destdoc11.close (wdSaveChanges)

'close the Attachment sheet
srcDoc.close (wdDoNotSaveChanges)

I retraced my steps revisted posts from April and use of bookmarks on the 
FAQ word site and I can't see what could cause this glitch.
Corrupt VBA or the bookmarks in the original letter?

Any ideas appreciated.


RE: run-time error 13 - Type mismatch (don't know why)

Postby TlogVkJBIERldmVsb3Blcg » Thu, 08 Nov 2007 10:15:00 GMT


I'm assuming that at some point in your code you have declared "bmrange" as 
a Range object, yes? And have you tried putting in some code to check to 
ensure that the "section11" bookmark actually exists in "destdoc11"? These 
are the only two reasons I can think of for a 'type mismatch' error, and the 
first case seems the most likely. If you don't explicitly tell Word that 
"bmrange" is a Range object (and don't use Option Explicit) it will create 
"bmrange" as a Variant type variable, and you may not be able to load a Range 
into it. If it's just a matter of not being able to find the bookmark I would 
expect a 'member of collection does not exist' type error instead.

The Kiwi Koder

RE: run-time error 13 - Type mismatch (don't know why)

Postby anVzdGFsb3N0Z3J1bnQ » Thu, 08 Nov 2007 10:58:00 GMT

Yes bmrange is declared as a range and option explicit is the case for the 
module behind this headache - so to speak.

I am automating from an access database - not sure now if thats a problem - 
but it worked before so I have to discount that.

The bookmark is there as the first part is to mail merge some data. The 
letter is saved. 
Destdoc11 becomes the letter.
I've checked the letter that is produced first to find the bookmarks (there 
are 11) and appear OK.

Write some code to check the bookmark - ummm.


RE: run-time error 13 - Type mismatch (don't know why)

Postby TlogVkJBIERldmVsb3Blcg » Thu, 08 Nov 2007 11:25:00 GMT

ell that blows that theory. <g>

Unfortunately, I'm not familiar enough with Access to determine if it's
playing a role, but as you say, it worked before...

As for checking for the existence of the bookmark, that's just a couple of
lines. Bookmarks support an 'Exists' method, so it's just a matter of:

If destdoc11.Bookmarks.Exists("section11") Then
'do the stuff you want to do with the bookmark
'handle the error however you think it should be handled
End If

I'm afraid that exhausts my supply of suggestions, altho maybe as part of
the debugging process you might want to put something in after you check for
the existence of the bookmark that will let you confirm that the right
bookmark is being used, such as:

MsgBox destdoc11.Bookmarks.("section11").Range.Text

I've also found that sometimes just working with the Bookmark Range object
causes problems, but the workarounds (selecting the Bookmark Range and then
working with the Selection Range object instead) are ugly and probably not

If none of this helps, let's hope that somebody else has some ideas.
The Kiwi Koder

"justalostgrunt" wrote:

RE: run-time error 13 - Type mismatch (don't know why)

Postby anVzdGFsb3N0Z3J1bnQ » Thu, 08 Nov 2007 12:17:01 GMT

Will place that snipet of code into the routine and see what transpires.

Read somewhere that word is unpredictable and what may work on one computer
may not work on another. Something to do wth defining a page, But a bookmark
is a bookmark - unpredicatable blitters.

Thanks for your help.

Best Regards

"NZ VBA Developer" wrote:

Similar Threads:

1.Error: run-time error 13 Type mismatch

I get this error every time I close Word 2002.  Anyone 
know how to fix it?

2.Run-time error 13 - Type mismatch

I get the run-time error everytime I close a document in 
Word 2002, otherwise everything works fine. I saw the 
responses to others that have similar problems and tried 
the "fixes". I have disabled the Norton office plug-in, 
use Acrobat 5.0.5 and run Winfax 5.1 so they don't seem 
to be the problem as Suzanne Barnhill kindly suggested (1-
20-04, 9:51pm). Any other ideas would be greatly 

3.MS Word - Run-time error '13' : Type mismatch

When closing any MS Word document, I get a "Run-time 
error '13': Type mismatch" message in a window 
titled "Microsoft Visual Basic". The window only allows 
me to select "end". I am using Office XP Professional. I 
am a computer novice, so any help or guidance would be 
really appreciated.

4.Run-time error '13' type mismatch on close

all of a sudden, every time I close word 2000, I get the 
error Microsoft Visual Basic, 'run-time error '13' type 
mismatch.  I hit end and word closes.  wondering what can 
be done.



5.Run-time error '13'" Type mismatch when I run my VBA procedure

    I get a Run-time error '13'" Type mismatch, when I try to run a VBA macro 
to use an email template to create an email, and send an attachment
    When I click the debug button, the following line is highlighted:
            Set objOutlookAttach = .Attachments.Add(strAttch01Nam)

Any insights or suggestions  would be much appreciated.

P.s. Here's the whole macro:

Sub CreateFromTemplate()
    Dim myOlApp As Outlook.Application
    Dim myItem As Outlook.MailItem
    Dim strTemplatNam As String
    Dim objOutlookMsg As Outlook.MailItem
    Dim objOutlookRecip As Outlook.Recipient
    Dim objOutlookAttach As Outlook.MailItem
    Dim strAttch01Nam As String
    strTemplatNam = "C:\Documents and Settings\marxp\Application 
    strAttch01Nam = "E:\Archive.2005-04-21-00-30.rar.lst.txt"
    Set myOlApp = CreateObject("Outlook.Application")
    Set myItem = myOlApp.CreateItemFromTemplate(strTemplatNam)
    With myItem
      ' Add the To recipient(s) to the message. Substitute
      ' your names here.
            'Set objOutlookRecip = .Recipients.Add(" XXXX@XXXXX.COM ")
            ' objOutlookRecip.Type = olTo
        ' Set the Subject, Body, and Importance of the message.
        .Subject = "This is an Automation test with Microsoft Outlook"
        .Body = "Last test." & vbCrLf & vbCrLf
        .Importance = olImportanceHigh  'High importance
        ' Add attachments to the message.
        If Not IsMissing(strAttch01Nam) Then
           Set objOutlookAttach = .Attachments.Add(strAttch01Nam)
        End If
    End With
End Sub

Return to MS WORD


Who is online

Users browsing this forum: No registered users and 55 guest