Opeing excel Template with access

B

Ben Price

I am having a trouble opening a microsoft excel template
with microsoft acess i have put a command button choosing
to run excel and the template but it actually runs the
template not the document created by the template, this
also happens when i try to open a microsoft word
template. Here is the macro:

Private Sub Excel_Click()
On Error GoTo Err_Excel_Click

Dim stAppName As String

stAppName = "Excel.exe
U:\Files\Coursework\Assignment_3\SYSTEM32
\Data_Files\INVOICE.XLT"
Call Shell(stAppName, 1)

Exit_Excel_Click:
Exit Sub

Err_Excel_Click:
MsgBox Err.Description
Resume Exit_Excel_Click

End Sub

Any help would be great.
 
D

Dave Peterson

This worked ok from MSWord.

Option Explicit
Sub testme01()

Dim myXL As Object
Dim XLWkbk As Object
Dim myTemplateName As String

Set myXL = Nothing
On Error Resume Next
Set myXL = GetObject(, "Excel.Application")
If Err.Number = 429 Then
Set myXL = CreateObject("Excel.Application")
End If
On Error GoTo 0

myXL.Visible = True

myTemplateName = "u:\Files\Coursework\Assignment_3\" _
& "SYSTEM32\Data_Files\INVOICE.XLT"

Set XLWkbk = myXL.workbooks.Add(myTemplateName)

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top