PDA

Click to See Complete Forum and Search --> : Type missmatch error


JohnL55
Jan 8th, 2000, 09:41 PM
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

MartinLiss
Jan 9th, 2000, 03:17 AM
Here is a different approach. Does it give the properties you want?

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