switchboard

D

David M. Fizer

Hello,


Is it possible to open a word document or excel spreadsheet using the
switchboard in access?



TIA,
David
 
T

Tom Wickerath

Hi David,

The short answer to your question is "Yes", it is possible. What's not so
obvious from your question is are you using a switchboard that was created
using the Switchboard wizard, or one that you created yourself (ie. an
unbound form)? Also, are you wanting a button that opens the same Word
doucment every time, or just Word so that you can select the file to open?


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

:

Hello,

Is it possible to open a word document or excel spreadsheet using the
switchboard in access?


TIA,
David
 
D

David M. Fizer

Hello Tom

Yes I would be using a switchboard that was created by the wizard but if
necessary to get it to work I would create my own. I have a couple of
documents already made and would just want to use a button or two on
switchboard to open each of them or atleast take the user to the folder
where they are stored.

Thanks you,
David
 
T

Tom Wickerath

Hi David,

Here is a simple example for opening a hard-coded Word document. First, open
the switchboard manager wizard and add a new command: Run Code. Use a
Function Name such as: OpenWordDoc. (If you use a different name, then make
a note of the new name). Then exit the switchboard wizard.

Create a new module. Copy and paste the following code into this module:

'****************BEGIN CODE*********************

Option Compare Database
Option Explicit

Public Sub OpenWordDoc()
On Error GoTo ProcError

Dim oApp As Object
Dim oDoc As Object
Dim strDocName As String

strDocName = "Full path to your Word document"

Set oApp = CreateObject("Word.Application")
Set oDoc = oApp.Documents.Open(fileName:=strDocName)
oApp.Visible = True



ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure OpenWordDoc..."
Resume ExitProc

End Sub

'****************END CODE*********************

The strDocName string variable defines the full path (ie. path + filename)
to your document. This is why I termed it "hard-coded". For example:

strDocName = "C:\Documents and Settings\UserName\My Documents\MyDoc.doc"

This is just a start. You can also use a command button on your switchboard
to open a new form, which includes a listbox with several Word documents
listed. This form would have a command button that would open whatever Word
document was selected in the listbox (you'd want to set the Multi Select
property to None, so that the user could select only one Word document at a
time). Then you pass the full path of the selected document file into the
function as a parameter.


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

:

Hello Tom

Yes I would be using a switchboard that was created by the wizard but if
necessary to get it to work I would create my own. I have a couple of
documents already made and would just want to use a button or two on
switchboard to open each of them or atleast take the user to the folder
where they are stored.

Thanks you,
David
__________________________________________

Tom Wickerath wrote:

Hi David,

The short answer to your question is "Yes", it is possible. What's not so
obvious from your question is are you using a switchboard that was created
using the Switchboard wizard, or one that you created yourself (ie. an
unbound form)? Also, are you wanting a button that opens the same Word
doucment every time, or just Word so that you can select the file to open?


Tom

http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________

:

Hello,

Is it possible to open a word document or excel spreadsheet using the
switchboard in access?


TIA,
David
 
Top