Making a command button open as specific word doc

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hey everyone

I have several command buttons on my form all in charge of exporting
different sets of data to different text files, at the end of this event i
want to open specific word documents, I sort of want this to be automated, as
administrative people will work the system, not me, so the less they do the
better.

I cant find any code to run this request.

any help would be appreciated.
 
The following example uses late binding so that it is not dependent on a
specific version of Word. If you want to look up the details, some keywords
to look up are 'automation', 'late binding' and 'early binding'.

Private Sub Command4_Click()

Dim objWord As Object

Set objWord = CreateObject("Word.Application")

'Assumes document in same folder as MDB.
objWord.Documents.Open CurrentProject.Path & "\test.doc"
objWord.Visible = True

End Sub

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Thanks heaps Brendan, That's perfect!!
Brendan Reynolds said:
The following example uses late binding so that it is not dependent on a
specific version of Word. If you want to look up the details, some keywords
to look up are 'automation', 'late binding' and 'early binding'.

Private Sub Command4_Click()

Dim objWord As Object

Set objWord = CreateObject("Word.Application")

'Assumes document in same folder as MDB.
objWord.Documents.Open CurrentProject.Path & "\test.doc"
objWord.Visible = True

End Sub

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Back
Top