- 1
Open a database in Access 2007. Click on the "Database Tools" tab and then "Visual Basic" to open the Visual Basic Editor.
- 2
Click on "Tools" and then "References" in the Visual Basic Editor. The References dialog box appear.
- 3
Scroll through the list of Reference Libraries until you find the Microsoft 12.0 Object Library you want to add. For instance, you can add the "Microsoft OneNote 12.0 Object Library" or "Microsoft Word 12.0 Object Library." You can add more than one Reference Library if you choose to. Click on the box next to Reference Library that you want to add and then click on "OK" when you are done.
- 4
Set the reference in the VBA code. For example, if you added the Microsoft Word 12.0 Object Library and you want to use it to open a Word document, use the following code:
"Sub OpenWordDoc ()
Dim appWord as Word.Application
Dim wrdWordDoc as Word.Document
Set appWord = CreateObject("Word.Application")
Set wrdWordDoc = appWord.Documents.Open("C:\Documents\example.docx") 'filepath to a Word document
End Sub"
You can do other things like editing documents, creating new documents and printing documents now that you have set the reference to the Word object reference library.
- 5
Click the "Save" button in Visual Basic Editor to save the changes.
5/14/11
How to Set a Reference to Microsoft 12.0 Object Library in Access 2007
Reference libraries are used to access additional functions, procedures, methods and objects. In Microsoft Access, the Microsoft 12.0 Object libraries allow you to access other Microsoft programs using Visual Basic for Applications. There are several Microsoft 12.0 Object libraries, one for each of the Microsoft Office applications. You can set a reference for one or more of these libraries to have access to the objects when creating dynamic database programs inside of Microsoft Access.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment