Results 1 to 2 of 2

Thread: Type missmatch error

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 1999
    Location
    Milford, NH
    Posts
    15

    Post

    No matter how I define strA I get type mismatch error.

    'Open word document and display in MSG
    'box the document propertys'
    'Defined strA many different ways with
    'not luck
    'Run time error 122 - Type mismatch
    Dim wd As Object
    Dim strA As String
    Dim intB As Integer
    Dim strB As String
    Dim intCount As Integer
    Set wd = CreateObject("Word.Basic")
    wd.FileOpen "a:SummaryTest.doc"
    For Cnt = 1 To wd.CountDocumentProperties()
    strA = wd.DocumentPropertyName$(Cnt)
    If wd.DocumentPropertyType(strA) = 1 Then
    strB = wd.GetDocumentProperty(strA)
    Else
    'Run time error 122 - Type mismatch
    strB = wd.GetDocumentProperty$(strA)
    MsgBox "Property " & strA & " = " & strB
    End If
    Next
    wd.FileClose 2
    Set wd = Nothing

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    Here is a different approach. Does it give the properties you want?
    Code:
    Dim wd As Word.Application 
    Dim MyRange
    Dim prop
    Dim Cnt As Integer
    
    Set wd = New Word.Application
    wd.Documents.Open FileName:="a:SummaryTest.doc"
    Set MyRange = ActiveDocument.Content
    MyRange.Collapse Direction:=wdCollapseEnd
    For Each prop In ActiveDocument.BuiltInDocumentProperties
        With MyRange
            On Error Resume Next
            MsgBox prop.Name & "= " & prop.Value
        End With
    Next
    wd.Documents.Close
    Set wd = Nothing
    ------------------
    Marty

Posting Permissions

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



Click Here to Expand Forum to Full Width