Type Mismatch error

  • Thread starter Tarjei T. Jensen
  • Start date
T

Tarjei T. Jensen

I keep getting "Type mismatch" error on xfield_list_Object(bookRange) below.
I'm completely at a loss understanding why this should be so. After all the
xfield_list_Object procedure expects a range object.

I'm sure that there is something I have overlooked, but I can't find what.

Suggestions welcome!

---- code listing ----

Private Sub Set_Bookmark_Text(theName As String, theContent As String)
Dim bookMK As Bookmark
Dim bookRange As Range
Dim bookName As String
Dim rng As Range

[snip]

For Each bookMK In ActiveDocument.Bookmarks

Set bookRange = bookMK.Range
bookName = bookMK.Name

[snip]

ElseIf ActiveDocument.Bookmarks.Exists(theName) Then
xfield_list_Object (bookRange) ' <------ type mismatch
bookRange.Text = theContent
ActiveDocument.Bookmarks.Add bookName, bookRange
Debug.Print " bookmark re-set"
Exit For
End If
'Debug.Print " next bookMK"
Next bookMK
End If

Debug.Print "exit set_Bookmark_Text " & theName

End Sub

Private Sub xfield_list_Object(objbk As Range)
Dim fld As FormField
Dim fld2 As Field

Debug.Print "enter field_list_object"

For Each fld In objbk.FormFields
Debug.Print " formfield::" & fld.Name & ":: " & fld.Type & " " &
fld.Creator
Next fld

For Each fld2 In objbk.Fields
Debug.Print " field ::" & fld2.Type & ":: " & fld2.Kind
Next fld2
Debug.Print "exit field_list_object"
End Sub
 
H

Helmut Weber

Hi Tarjei,
it is the way you pass the argument to your procedure:
xfield_list_Object bookRange ' <-- no type mismatch
call xfield_list_Object(bookRange) ' <-- no type mismatch
But don't ask me why...
Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr(64) & "t-online.de"
Word XP, Windows 2000
 
T

Tarjei T. Jensen

Helmut Weber said:
it is the way you pass the argument to your procedure:
xfield_list_Object bookRange ' <-- no type mismatch
call xfield_list_Object(bookRange) ' <-- no type mismatch
But don't ask me why...

That was spot on. Thanks a lot! I've stared at the piece of code for hours
without noticing. I was convinced that there was some sort of stupid
mistake, but were unable to see.

Diagnosis: Too much perl and Unix.

greetings,
 
P

Peter Hewett

Hi Tarjei T. Jensen

You've declared your procedure as a Sub but your calling it as a Function!
Change:

xfield_list_Object (bookRange)

to
xfield_list_Object bookRange

HTH + Cheers - Peter
 

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