By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,425 Members | 2,549 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,425 IT Pros & Developers. It's quick & easy.

read/write word document properties from Access

P: 1
I create an application with Access 2000 and I wish to read/write the properties of a specified word document. I use dsofile.dll
my code is
Expand|Select|Wrap|Line Numbers
  1. Function fGetDocProps(strInFile As String, strProp As String) 
  2. Dim objWord As Object, objDocProps As Object 
  3.  
  4.  
  5.     On Error GoTo Err_fGetDocProps 
  6.     Set objWord = CreateObject("Word.Application") 
  7.     objWord.Documents.Open strInFile 
  8.     Set objDocProps = objWord.ActiveDocument.BuiltInDocumentProperties 
  9.     fGetDocProps = objDocProps(strProp) 
  10.  
  11. Exit_fGetDocProps: 
  12.     objWord.Application.Quit savechanges:=False 
  13.     Set objDocProps = Nothing 
  14.     Set objWord = Nothing 
  15.     Exit Function 
  16.  
  17. Err_fGetDocProps: 
  18.     fGetDocProps = "Error: Probably File/Property does not exist." 
  19.     Resume Exit_fGetDocProps 
  20. End Function 
  21.  
  22. Function fEnumProps(strInFile As String) 
  23. Dim objWord As Object, objDocProps As Object 
  24. Dim i As Integer 
  25.     On Error Resume Next 
  26.     Set objWord = CreateObject("Word.Application") 
  27.     With objWord 
  28.         .Documents.Open strInFile 
  29.         Set objDocProps = 
  30. objWord.ActiveDocument.BuiltInDocumentProperties 
  31.         For i = 0 To objDocProps.Count - 1 
  32.             Debug.Print objDocProps(i).Name, objDocProps(i).Value 
  33.         Next i 
  34.     End With 
  35.     objWord.Application.Quit savechanges:=False 
  36.     Set objWord = Nothing 
  37. End Function 
  38. ***************************************************** 
  39.  
if I want to read a property (for example "title") I write

msgbox (fGetDocProps("C:\test\sample.doc","Title"))

but I don't understand how to write and change that property
thanks
Maurizio
Oct 13 '07 #1
Share this Question
Share on Google+
3 Replies


nico5038
Expert 2.5K+
P: 3,072
The general way to assign a value to properties is to use:
Object.propertyname = "value"
or
Object.Properties("propertyname") = "value"

However not all properties can be written, some are "read-only".....

Nic;o)
Oct 13 '07 #2

NeoPa
Expert Mod 15k+
P: 31,494
I'm afraid that, although you're using Access as a coding base, this question is really about a separate library (DLL). I will happily leave it here but there may not be many of our Access experts who know much about this library for accessing the properties of an MS Word via the file-system. Have you tried using Google to search for items on that library? Or even the procedure call you used to read the property?
Oct 13 '07 #3

NeoPa
Expert Mod 15k+
P: 31,494
I did a quick Google for you and found the following Microsoft KnowledgeBase article which should help you do exactly what you want (The Dsofile.dll files lets you edit Office document properties when you do not have Office installed).
Good luck.
Oct 13 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.