Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to export word built-in and custom properties to MS Access?

Status
Not open for further replies.

Tekdame

Technical User
Mar 24, 2006
5
AU
I'm trying to export word built-in and custom properties from loads of word documents to access to build a document management system. Any one knows how to create macro in Access? I'm know some Access and basic macro only. Anyone got an example?
 
One can communicate with word via VBA, not with macro's.
In VBS you should add a reference to word via Tolols/Refrences in the VBA window. When in the refrences window press "M" (for microsift) and move down until you see "Microsoft Word X.X Object Libery" tag this and press OK.

Her is some code that I use to set properties in word but this code will also show you the properties.

WordProp oWord, DLookup("EditorName", "Editor")

Function WordProp(ByVal oWord As Object, Optional Title, Optional Subj, Optional AdrID)
Dim Cat, KeyW
On Error Resume Next
If Not IsBlank(AdrID) Then
Cat = DLookup("CatText", "AddressCategory", "Category=" & AdrID)
KeyW = DLookup("EgenID", "AddressKeywords", "AdrID=" & AdrID)
KeyW = DLookup("Text", "Keywords", "EgenID='" & KeyW & "'")
End If
oWord.Visible = True
oWord.ActiveDocument.BuiltinDocumentProperties(wdPropertyTitle) = Title
oWord.ActiveDocument.BuiltinDocumentProperties(wdPropertyAuthor) = DLookup("EditorName", "Editor")
oWord.ActiveDocument.BuiltinDocumentProperties(wdPropertyCompany) = DLookup("LHead", "Editor")
oWord.ActiveDocument.BuiltinDocumentProperties(wdPropertyHyperlinkBase) = "oWord.ActiveDocument.BuiltinDocumentProperties(wdPropertyCategory) = Cat
oWord.ActiveDocument.BuiltinDocumentProperties(wdPropertyKeywords) = KeyW
oWord.ActiveDocument.BuiltinDocumentProperties(wdPropertyComments) = DLookup("LFooter", "Editor")
oWord.ActiveDocument.BuiltinDocumentProperties(wdPropertySubject) = Subj
End Function

Let me know if I can help further.

Herman
Say no to macros
 
Thanks. How do I get to the VBS section? I don't see Tools->References. You mentioned "In VBS you should add a reference to word via Tolols/Refrences in the VBA window
 
Hi "VBS" is a typo... sry, should read "VBA"
Use "Alt+F11" to get to the VBA window.

VBA stands for Visual Basic for Applications and is a close to VB (Visual Basic) programming language, used throughout the office package and other programs from M$

To create a module goto Insert, choose Module in the menu bar. You are now ready to start programming.

Once you are in the VBA-window and your code is running you you can tab thru the code using the keys F8 and F5.

I can see that I incl. a small function in my code "IsBlank" this checks for IsNull/IsEmpty/etc. all on one go. this is the function:

Function IsBlank(V As Variant) As Boolean
On Error Resume Next
V = "" & V
If Len(V) = 0 Then IsBlank = True
End Function

Drop this into your new module, save your module and give it a meaningfull name.


Herman
Say no to macros
 
To view your options in VBA try the "Locals window" found via View/Locals window"

Herman
Say no to macros
 
I am sounding really dumb but....I got only as far as the object library. For some reason WordProp Word isn't recognised. The Microsoft Word object is 9.0.

Does this vba help in importing Microsoft Word document properties (builtin and custom) to Microsoft Access from a specific filepath and folder? And what is the vba then for exporting fields into the document properties?


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top