Using other Office Applications from VBA (1 Viewer)

dsigner1

Registered User.
Local time
Today, 17:17
Joined
Jun 13, 2008
Messages
38
I have a fairly simple Access Application that needs to create a Word file in one form; And then open that file using the created name and path in another form. The word document should open in a separate window and when the window is closed, return to Access. I do not need to transfer any data from Access although it would be nicer if a simple Header string was placed in the Word Document. I have done Internet searches and have found code to do labels or include tables and other complex things. They all seem to use a different method to interface with the word file and seem to focus on specific problems with this part.

Please can any one define the approved method for one creating a new blank word file and two opening an existing word file in a separate window. Preferably, I would like late binding so that it does not require too much knowledge of the users system. Also I like to know what my code is doing so some pointers to additional information or explanation of the objects being used would be wonderful.

I am sure that there are many other readers who would like to know about this subject and all the references I can find skip the crucial bit and jump to specifics like templates going wrong and that sort of stuff. Once the basics are clear we less experienced programmers can either work out the tricky bits or seek help knowing that we have the basics in place.
 

JHB

Have been here a while
Local time
Today, 18:17
Joined
Jun 17, 2012
Messages
7,732
Place the below code behind a button's click event.
Search the Help-file, (in code window) in MS-Access for GetObject and CreateObject for explanation and more examples.
Code:
   Dim objApp As Object

  Set objApp = CreateObject("Word.Application")
  objApp.Visible = True 'Make the application visible to the user (if wanted)
  objApp.Documents.Add 'Create a new document 
  objApp.Documents.Add ("C:\PathToYouWordDocument\WordDokumentName.doc") 'Open an WordDokument
 

dsigner1

Registered User.
Local time
Today, 17:17
Joined
Jun 13, 2008
Messages
38
Thanks for the fast response. I will check it out but perhaps not so quickly - Working in a south facing office with minimal ventilation probably 90 something. Will report back when it is running.
 

Users who are viewing this thread

Top Bottom