Opening an Excel or Word file from Command Button

  • Thread starter Thread starter Elton, Ilona & Justin Wright
  • Start date Start date
E

Elton, Ilona & Justin Wright

Hello,

I feel sure the answer to this has been posted before, but a quick search of
the headers doesn't seem to show an answer.

How can I open an existing Word or Excel file from a Command Button on
Access - and when I do, will my db remain open.

To return, I presume I would need to code my word or excel files somehow,
but as a newbie to Access, and only knowing as much as I have taught myself,
aren't sure how I go about this.

Any help greatly appreciated.

Elton
 
If you use automation to open the file, you can manipulate it from within
Access, then close and return to Access. Or you can use the ShellExecute api
to actually open a file with Ecel or Word, then manually work from within
those programs. Here's some relevant links for sample code:

http://www.datastrat.com/Code/WordMerge.txt
http://www.mvps.org/access/modules/mdl0006.htm
http://www.mvps.org/access/api/api0018.htm
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
You can place a button on a form. The following code behind the button will
open a document:

application.FollowHyperlink "c:\data\Sales.xls"

The above would open a Excel document.

And, for word..

application.FollowHyperlink "c:\data\Sales.doc"
 
Elton said:
Hello,

I feel sure the answer to this has been posted before, but a quick search
of the headers doesn't seem to show an answer.

How can I open an existing Word or Excel file from a Command Button on
Access - and when I do, will my db remain open.

To return, I presume I would need to code my word or excel files somehow,
but as a newbie to Access, and only knowing as much as I have taught
myself, aren't sure how I go about this.

Any help greatly appreciated.

Elton
 
Arvin Meyer said:
If you use automation to open the file, you can manipulate it from within
Access, then close and return to Access. Or you can use the ShellExecute
api
to actually open a file with Ecel or Word, then manually work from within
those programs. Here's some relevant links for sample code:

http://www.datastrat.com/Code/WordMerge.txt
http://www.mvps.org/access/modules/mdl0006.htm
http://www.mvps.org/access/api/api0018.htm
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Albert D.Kallal said:
You can place a button on a form. The following code behind the button
will open a document:

application.FollowHyperlink "c:\data\Sales.xls"

The above would open a Excel document.

And, for word..

application.FollowHyperlink "c:\data\Sales.doc"


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(e-mail address removed)
http://www.members.shaw.ca/AlbertKallal
 
Albert D.Kallal said:
You can place a button on a form. The following code behind the button
will open a document:

application.FollowHyperlink "c:\data\Sales.xls"

The above would open a Excel document.

And, for word..

application.FollowHyperlink "c:\data\Sales.doc"


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(e-mail address removed)
http://www.members.shaw.ca/AlbertKallal
 
Arvin Meyer said:
If you use automation to open the file, you can manipulate it from within
Access, then close and return to Access. Or you can use the ShellExecute
api
to actually open a file with Ecel or Word, then manually work from within
those programs. Here's some relevant links for sample code:

http://www.datastrat.com/Code/WordMerge.txt
http://www.mvps.org/access/modules/mdl0006.htm
http://www.mvps.org/access/api/api0018.htm
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Elton said:
Hello,

I feel sure the answer to this has been posted before, but a quick search
of the headers doesn't seem to show an answer.

How can I open an existing Word or Excel file from a Command Button on
Access - and when I do, will my db remain open.

To return, I presume I would need to code my word or excel files somehow,
but as a newbie to Access, and only knowing as much as I have taught
myself, aren't sure how I go about this.

Any help greatly appreciated.

Elton
 
Back
Top