DPrometheus
Well-known member
Hi there,
Ive encountered the following problem and Im really clueless.
For work Ive made a word host application, and now we need to switch templates in it. Ive made a custom ribbon where a combobox lists all templates. These templates are loaded in the combobox_change event. See code listing 1 below.
Ive a Word template (.dotm) called Spec.dotm. This template does nothing more then redirect to another template (Word07Def.dotm), which will be activated as some sort of global template (This enables me to switch documents). This global template contains the ribbon adjustments, and VBA code to handle the ribbon controls
If I do this in Word 2007 everything works fine, however if I do this in my host application (Which does nothing else then just open Spec.dotm, which succesfully redirects to Word07Def) it fails with error 91: object variable or with block not set. when I try to switch templates. If I check the Globally loaded templates I see Word07Def activated. Whenever it fails I see word flickering once or twice (which indicates it loads the other document, I guess) and then opening my previous document with the error code.
Weird thing is, if I do this in Word 2007 it works like a charm?!
I have word running in a panel control like code listing 2.
code 1:
Ive encountered the following problem and Im really clueless.
For work Ive made a word host application, and now we need to switch templates in it. Ive made a custom ribbon where a combobox lists all templates. These templates are loaded in the combobox_change event. See code listing 1 below.
Ive a Word template (.dotm) called Spec.dotm. This template does nothing more then redirect to another template (Word07Def.dotm), which will be activated as some sort of global template (This enables me to switch documents). This global template contains the ribbon adjustments, and VBA code to handle the ribbon controls
If I do this in Word 2007 everything works fine, however if I do this in my host application (Which does nothing else then just open Spec.dotm, which succesfully redirects to Word07Def) it fails with error 91: object variable or with block not set. when I try to switch templates. If I check the Globally loaded templates I see Word07Def activated. Whenever it fails I see word flickering once or twice (which indicates it loads the other document, I guess) and then opening my previous document with the error code.
Weird thing is, if I do this in Word 2007 it works like a charm?!
I have word running in a panel control like code listing 2.
code 1:
Code:
Sub TypeBriefCombo_Change(control As IRibbonControl, text As String)
On Error Resume Next
Dim openFile As String
openFile = ""
Select Case text
Case "Poliklinische brief"
set filename string
openFile = "K:\mso\AppInApp\Klinisch.docx"
Templates("K:\mso\AppInApp\Klinisch.dotm").OpenAsDocument
Case "Klinische brief"
openFile = "K:\mso\AppInApp\Klinisch.docx"
Case "Ontslagbrief"
openFile = "K:\mso\AppInApp\Ontslag.docx"
Case "Pati