L
lgbjr
Hi All,
I'm trying to read some custom document properties from MS Word docs from
within Excel. I've found a VB.NET sample that uses the dsofile.dll and this
seems to be what I want, but I am not very familiar with VBA, so I'm having
some difficulty getting the VB.NET code translated to work within VBA.
I've searched around google and have not found anything except that many
people say that it should be easy to make the dll work using VBA (though I
haven't seen any proof of how easy it is or that it actually works)
Basically, what I want to do is use a filesearch to generate a foundfiles
object with all of the word documents in a directory, then loop through the
files and get the custome properties. Below is what I'm trying.
I get a permission denied error when I get to opening the file. I've tried
using the ReadOnly options, but VBA complains if I try to add more than just
the file name argument:
Dim DSO As DSOFile.OleDocumentProperties
Dim CP As DSOFile.CustomProperty
With Application.FileSearch
.LookIn = ActiveWorkbook.Path
.FileType = msoFileTypeWordDocuments
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
Set DSO = CreateObject("DSOFile.OleDocumentProperties")
DSO.Open (.FoundFiles.Item(i)) 'permission denied
'DSO.Open(.FoundFiles.Item(i),True) ' VBA error saying it
expects an =
For Each CP In DSO
If CP.Name = "Eval_Period" Then
If CP.Value = "4th Quarter, 2005" Then
If CP.Name = "TK" Then
If CP.Value = "VG" Then
TKVG = TKVG + 1
ElseIf CP.Value = "G" Then
TKG = TKG + 1
ElseIf CP.Value = "N" Then
TKN = TKN + 1
ElseIf CP.Value = "NG" Then
TKNG = TKNG + 1
End If
End If
End If
End If
Next CP
DSO.Close
Next i
End If
End With
Has anyone used the dsofile.dll in VBA (Excel) with any success? If so, can
someone give me a little code snippet showing how to use the functions in
dsofile.dll?
TIA
Lee
I'm trying to read some custom document properties from MS Word docs from
within Excel. I've found a VB.NET sample that uses the dsofile.dll and this
seems to be what I want, but I am not very familiar with VBA, so I'm having
some difficulty getting the VB.NET code translated to work within VBA.
I've searched around google and have not found anything except that many
people say that it should be easy to make the dll work using VBA (though I
haven't seen any proof of how easy it is or that it actually works)
Basically, what I want to do is use a filesearch to generate a foundfiles
object with all of the word documents in a directory, then loop through the
files and get the custome properties. Below is what I'm trying.
I get a permission denied error when I get to opening the file. I've tried
using the ReadOnly options, but VBA complains if I try to add more than just
the file name argument:
Dim DSO As DSOFile.OleDocumentProperties
Dim CP As DSOFile.CustomProperty
With Application.FileSearch
.LookIn = ActiveWorkbook.Path
.FileType = msoFileTypeWordDocuments
If .Execute > 0 Then
For i = 1 To .FoundFiles.Count
Set DSO = CreateObject("DSOFile.OleDocumentProperties")
DSO.Open (.FoundFiles.Item(i)) 'permission denied
'DSO.Open(.FoundFiles.Item(i),True) ' VBA error saying it
expects an =
For Each CP In DSO
If CP.Name = "Eval_Period" Then
If CP.Value = "4th Quarter, 2005" Then
If CP.Name = "TK" Then
If CP.Value = "VG" Then
TKVG = TKVG + 1
ElseIf CP.Value = "G" Then
TKG = TKG + 1
ElseIf CP.Value = "N" Then
TKN = TKN + 1
ElseIf CP.Value = "NG" Then
TKNG = TKNG + 1
End If
End If
End If
End If
Next CP
DSO.Close
Next i
End If
End With
Has anyone used the dsofile.dll in VBA (Excel) with any success? If so, can
someone give me a little code snippet showing how to use the functions in
dsofile.dll?
TIA
Lee