ACC2000: How to Start Another Application from a Data Access PageID: Q234303
|
This article shows you how to start another application from a Microsoft Access data access page.
The following example demonstrates how to start an application and to load a file whose name you type in a text box. This example starts Microsoft Word for Windows and loads a document that you specify.
Id: txtApp
Left: 2in
Top: 0.5in
Width: 1in
FontWeight: bold
InnerText: Application Name:
Left: 0in
TextAlign: right
Top: 0.5in
Width: 2in
Id: txtDoc
Left: 2in
Top: 0.75in
Width: 4in
FontWeight: bold
InnerText: Path and File Name:
Left: 0in
TextAlign: right
Top: 0.75in
Width: 2in
Id: cmdOpenApp
FontWeight: bold
InnerText: Open App
Left: 2.5in
Top: 1in
Id: cmdCloseApp
FontWeight: bold
InnerText: Close App
Left: 2.5in
Top: 1.25in
<SCRIPT language=vbscript>
<!--
Option Explicit
Dim Obj
-->
</SCRIPT>
<SCRIPT event=onclick for=cmdOpenApp language=vbscript>
<!--
Dim strApp, strDoc
Dim intPosition
strApp = document.all.item("txtApp").Value
strDoc = document.all.item("txtDoc").Value
If Not IsNull(strApp) And strApp <> "" Then
Set Obj = CreateObject(strApp & ".Application")
Obj.Application.Visible = True
Else
MsgBox "Must enter an Application Name."
Exit Sub
End If
If Not IsNull(strDoc) and strDoc <> "" Then
Select Case UCase(StrApp)
Case "ACCESS"
Obj.OpenCurrentDatabase strDoc
Case "EXCEL"
Obj.Workbooks.Open strDoc
Case "WORD"
Obj.Documents.Open strDoc
Case Else
MsgBox "Application Unknown."
Exit Sub
End Select
End If
-->
</SCRIPT>
<SCRIPT event=onclick for=cmdCloseApp language=vbscript>
<!--
Obj.Application.Quit
Set Obj = Nothing
-->
</SCRIPT>
Additional query words:
Keywords : kbdta AccDAP DAPScriptHowTo
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: July 26, 1999