(Solved) – Trying to call an Excel document from a Word document

(solved)-–-trying-to-call-an-excel-document-from-a-word-document

I have a tab set up in Word where users can click on the name of a particular document and it will open as a new Word document. I need to add an excel template to be called up the same way, but I think I need to define it some way so Word will do that.

Here is the routine, and all of the .dot and .dotm templates are called up with no problem. But Case “btnHR7” has an Excel template and it does not work as I have it:

Sub SplitHR_OnAction(ByVal control As IRibbonControl)
Select Case control.ID
Case “btnHR1″
Documents.Add Template:=”FAPVMsstu_sharedTemplatesSSTUWA NormalACCIDENT INCIDENT FORM.dotm”, NewTemplate:=False
Case “btnHR2″
Documents.Add Template:=”FAPVMsstu_sharedTemplatesSSTUWA NormalACCIDENT INCIDENT FORM.dotm”, NewTemplate:=False
Case “btnHR3″
Documents.Add Template:=”FAPVMsstu_sharedTemplatesSSTUWA NormalAD-HOC TIME TAKEN.dot”, NewTemplate:=False
Case “btnHR4″
Documents.Add Template:=”FAPVMsstu_sharedTemplatesSSTUWA NormalApplication for Leave.dot”, NewTemplate:=False
Case “btnHR5″
Documents.Add Template:=”FAPVMsstu_sharedTemplatesSSTUWA NormalApplication for RDOs – AD.dot”, NewTemplate:=False
Case “btnHR6″
Documents.Add Template:=”FAPVMsstu_sharedTemplatesSSTUWA NormalApplication for RDOs – IN.dot”, NewTemplate:=False
Case “btnHR7”
Documents.Add Template:=oExcel.Workbooks.Open(“FAPVMsstu_sharedTemplatesSSTUWA NormalTime Sheet Casual.xltm”), NewTemplate:=False
Case “btnHR8″
Documents.Add Template:=”FAPVMsstu_sharedTemplatesSSTUWA NormalADMIN – ELECT WORKING HRS.dotm”, NewTemplate:=False
Case “btnHR9″
Documents.Add Template:=”FAPVMsstu_sharedTemplatesSSTUWA NormalNEW EMPLOYEE INFORMATION.dotm”, NewTemplate:=False
Case “btnHR10″
Documents.Add Template:=”FAPVMsstu_sharedTemplatesSSTUWA NormalOvertime Application.dot”, NewTemplate:=False
Case “btnHR11″
Documents.Add Template:=”FAPVMsstu_sharedTemplatesSSTUWA NormalPD APPLICATION FORM.doc”, NewTemplate:=False
Case “btnHR12″
Documents.Add Template:=”FAPVMsstu_sharedTemplatesSSTUWA NormalRDO Alteration.dotm”, NewTemplate:=False
Case “btnHR13″
Documents.Add Template:=”FAPVMsstu_sharedTemplatesSSTUWA NormalREQUEST FOR TRAVEL.dot”, NewTemplate:=False
Case “btnHR14″
Documents.Add Template:=”FAPVMsstu_sharedTemplatesSSTUWA NormalTOIL APPLICATION – CL.dot”, NewTemplate:=False
Case “btnHR15″
Documents.Add Template:=”FAPVMsstu_sharedTemplatesSSTUWA NormalTOIL APPLICATION – IN.dot”, NewTemplate:=False
End Select

End Sub

I have made sure that under References the Microsoft Excel 14.0 Object Library is ticked.

The actual tab in word uses MyRibbon.xml to show the icons for the different documents, and the routine containing the above is:

        

How can I call the excel template from the routines? Do I need to add a subroutine somewhere defining the Excel document?

Leave a Reply

Your email address will not be published. Required fields are marked *