PDA

View Full Version : Solved: Type Mismatch



LukeWarm
01-20-2006, 05:55 AM
Hi,

I'm new here...
Did an extensive search at Microsoft, the Internet an a quick one here
Can't find what I'm looking for.

My code:

Sub test()
'Word VBA 2002; Option Explicit

Dim aCustProp As CustomProperty
'type mismatch
For Each aCustProp In ActiveDocument.CustomDocumentProperties
MsgBox aCustProp.Value
Next aCustProp

Dim aDocVar As Variable
'NO type mismatch
For Each aDocVar In ActiveDocument.Variables
MsgBox aDocVar.Value
Next aDocVar

End Sub

First For Next Loop gives a type mismatch; second one is OK
Drives me crazy. Any ideas?


PS: Great to have a formum on VBA!!!

regards,
Luke

Bob Phillips
01-20-2006, 06:02 AM
Luke,

Declare it as a Documentproperty


Dim aCustProp As DocumentProperty

LukeWarm
01-20-2006, 06:10 AM
Wow...

Fast AND right..

thanks!