Help with opening an Excel file from within a Word VBA

A

Android

Private Sub cmdCBA_Click()
Dim ExcelSheet As Object
Set ExcelSheet = CreateObject("Excel.Application")
ExcelSheet.Workbooks.Add ("O:\Corporate Services\" _
& "Corporate Planning\Methodology and
Processes\" _
& "tplCBA.xlt")

MsgBox ExcelSheet.StartupPath

'Set ExcelSheet = Nothing


' Documents.Add Template:="O:\Corporate Services\" _
' & "Corporate Planning\Methodology and
Processes\" _
' & "tpl-Post Project Review.dot"

End Sub
 
A

Android

Slippery fingers. Sent before I could clean up the code.
What I meant to ask was this:

Trying to open an Excel workbook from within a Word
document. The workbook should be based on a template.

Having trouble withy this. Could someone please tell me
what I'm doing wrong. The closest without error I came to
is the following:

Private Sub cmdCBA_Click()
Dim ExcelSheet As Object
Set ExcelSheet = CreateObject("Excel.Application")
ExcelSheet.Workbooks.Add ("O:\..... \tplCBA.xlt")
End Sub

This does not give errors, but also does nothing. Also,
even though I'm using the same folder for the document and
the template, I still need to specify the full path for
some reason.

Regards,

Android.
 
J

Joe Fawcett

Android said:
Slippery fingers. Sent before I could clean up the code.
What I meant to ask was this:

Trying to open an Excel workbook from within a Word
document. The workbook should be based on a template.

Having trouble withy this. Could someone please tell me
what I'm doing wrong. The closest without error I came to
is the following:

Private Sub cmdCBA_Click()
Dim ExcelSheet As Object
Set ExcelSheet = CreateObject("Excel.Application")
ExcelSheet.Workbooks.Add ("O:\..... \tplCBA.xlt")
End Sub

This does not give errors, but also does nothing. Also,
even though I'm using the same folder for the document and
the template, I still need to specify the full path for
some reason.

Regards,

Android.
You need to set ExcelSheet.visible = True.
 

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