RUNNING WORD

  • Thread starter Thread starter malcolmmabe
  • Start date Start date
M

malcolmmabe

I KNOW THAT YOU CAN CREATE A BUTTON THAT RUNS WORD/EXCEL
FROM ACCES, BUT HOW CAN IT BE SET UP TO OPEN A PARTICULAR
WORD/EXCEL DOCUMENT?
 
Malcolm,

If there isn't going to be any interaction between Access and Word, you can
use this:
http://www.pacificdb.com.au/MVP/Code/ExeFile.htm

However, if you want some form of interaction between Access and Word, you
need to use Automation:
Private WithEvents wrd As Word.Application
Private WithEvents doc As Word.Document
Private sPath2File As String '*** For example only

Private Sub Command0_Click()
sPath2File = "Z:\Document Flowchart.doc" '*** For example only

Set wrd = New Word.Application
wrd.Visible = True
Set doc = wrd.Documents.Open(sPath2File)
End Sub

Private Sub doc_Close()
MsgBox "The document was just closed."
End Sub

Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next

doc.Close wdDoNotSaveChanges
wrd.Quit wdDoNotSaveChanges
Set doc = Nothing
Set wrd = Nothing
End Sub

Private Sub wrd_Quit()
MsgBox "Word was just shut down."
End Sub

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
Malcolm,

Oh, I forgot to mention... You must add a reference to the Word Object
Library.

1. From any code module, select Tools | References.
2. Tick the Microsoft Word Object Library.
3. Click OK.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
Back
Top