Microsoft Word Automation from Microsoft Access MS Office

  • Slides: 9
Download presentation
Microsoft Word© Automation from Microsoft Access© MS Office Versions 2000 & 2002 by Ofer

Microsoft Word© Automation from Microsoft Access© MS Office Versions 2000 & 2002 by Ofer Shimrat for AUGSD

Introduction Automation Creation Manipulation Microsoft Word Microsoft Access Code Summary Conclusion 11 -14 -2002

Introduction Automation Creation Manipulation Microsoft Word Microsoft Access Code Summary Conclusion 11 -14 -2002 Microsoft Office Automation Environment Creating MS Word Object in MS Access Manipulating MS Word Object in MS Access Microsoft Word Environment Microsoft Access Environment Code Summary with 2 Examples Conclusion MS Word Automation from MS Access 2

Microsoft Office Automation History – DDE (Dynamic Data Exchange) Introduction – OLE (Object Linking

Microsoft Office Automation History – DDE (Dynamic Data Exchange) Introduction – OLE (Object Linking & Embedding) 1. 0 & 2. 0 Automation – Active X and COM (Component Object Model) Creation Manipulation Microsoft Word Microsoft Access Code Summary Conclusion 11 -14 -2002 Automation Concepts – Automation Client (i. e. MS Access) – Automation Server (i. e. MS Word) – Automation Type Library – Automation Object Model – Automation Object Types MS Word Automation from MS Access 3

Automation Creation Introduction Automation Declare an object variable New instance started automatically Instance is

Automation Creation Introduction Automation Declare an object variable New instance started automatically Instance is invisible Can also declare & instantiate manually Creation Manipulation Microsoft Word Microsoft Access Code Summary Conclusion Dim obj. Word As Word. Application Set obj. Word = Create. Object("Word. Application") Or Dim obj. Word As Word. Application Set obj. Word = New Word. Application Note: MDB, MDE, Run Time 11 -14 -2002 MS Word Automation from MS Access 4

Automation Manipulation Introduction Automation Creation Manipulation Microsoft Word Microsoft Access Code Summary Conclusion 11

Automation Manipulation Introduction Automation Creation Manipulation Microsoft Word Microsoft Access Code Summary Conclusion 11 -14 -2002 Objects have properties Properties can be manipulated obj. Word. Visible = True obj. Word. Caption = “Text” & Field Value obj. Word. Documents. Add (Doc. Name) MS Word Automation from MS Access 5

Microsoft Word Introduction Automation Use existing template (*. dot) Expose VBA in MS Word

Microsoft Word Introduction Automation Use existing template (*. dot) Expose VBA in MS Word 40 characters per bookmark – no spaces 16, 379 bookmarks per document Creation Manipulation Microsoft Word Microsoft Access Code Summary Conclusion 11 -14 -2002 Properties MS Word Automation from MS Access 6

Microsoft Access Somewhere begin your code with: Introduction Automation Creation Dim obj. Word As

Microsoft Access Somewhere begin your code with: Introduction Automation Creation Dim obj. Word As Word. Application Set obj. Word = Create. Object("Word. Application") Somewhere end your code with: obj. Word. Quit Set obj. Word = Nothing Manipulation Microsoft Word Microsoft Access Code Summary Conclusion 11 -14 -2002 VBA References MS Word Automation from MS Access 7

Code Summary Introduction Automation Creation Manipulation Microsoft Word Microsoft Access Code Summary Conclusion 11

Code Summary Introduction Automation Creation Manipulation Microsoft Word Microsoft Access Code Summary Conclusion 11 -14 -2002 Code Comments Declare variables Set variables Determine conditions Handle conditions Communicate to User Automate Word Leave user to save/exit Word Return to Access MS Word Automation from MS Access 8

Conclusion Introduction Automation Use it when Access reports won’t do Programmatically control MS Office

Conclusion Introduction Automation Use it when Access reports won’t do Programmatically control MS Office Useful in many ad hoc situations Creation Manipulation Microsoft Word Microsoft Access Code Summary Conclusion 11 -14 -2002 Ofer Shimrat (858) 484 -0400 ofer@soundoffcomputing. com MS Word Automation from MS Access 9