Consulting

Results 1 to 3 of 3

Thread: Solved: Type Mismatch

  1. #1
    VBAX Newbie
    Joined
    Jan 2006
    Posts
    2
    Location

    Solved: Type Mismatch

    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

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,445
    Location
    Luke,

    Declare it as a Documentproperty

    [vba]
    Dim aCustProp As DocumentProperty
    [/vba]

  3. #3
    VBAX Newbie
    Joined
    Jan 2006
    Posts
    2
    Location
    Wow...

    Fast AND right..

    thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •