Kevinofzûn
07-20-2011, 01:57 AM
Hello,
I am using Word 2003 on XP
I have made a userform with optionlists refering to a .dot (template)
On click this opens the template you choose via optionlist. In this template I have created another userform (shows on document open) which is linked to the template's Bookmarks.
The problem is that when I create a new word file with the template, the userform shows up and everything works (I see the new document). But when I use my first userform with the optionlist to choose which template I want to use I never get to see the new document. It exist though cause when I close word it asks me to save document2....
Has anyone got an idea how to show this document when I have filled in the userform
Here is my code
'//code of first userform (refering to template)
Private Sub CommandButton1_Click()
Dim objWord As Word.Application
Dim objDoc As Word.Document
If optVoltijdsO.Value = True Then
Set objWord = New Word.Application
Set objDoc = objWord.Documents.Add("C:\Documents and Settings\444236354\Application Data\Microsoft\Templates\Voltijdse loopbaanonderbreking voor ouderschapsverlof.dot")
End If
If optHalftijdsO.Value = True Then
Set objWord = New Word.Application
Set objDoc = objWord.Documents.Add("C:\Documents and Settings\444236354\Application Data\Microsoft\Templates\Haltijdse loopbaanonderbreking voor ouderschapsverlof.dot")
End If
End Sub
'// code which creates new doc based on template
Private Sub cmdOK_Click()
Dim strAanvang As String
If optAanvang = True Then strAanvang = "AGP"
Application.ScreenUpdating = False
With ActiveDocument
.Bookmarks("Aanvang").Range.Text = txtAanvang.Value
.Bookmarks("Aanvraag").Range.Text = txtAanvraag.Value
End With
Application.ScreenUpdating = True
Unload Me
End Sub
I have deleted som Dims, Ifs and Bookmarks since they don't matter.
Thank you in advance
I am using Word 2003 on XP
I have made a userform with optionlists refering to a .dot (template)
On click this opens the template you choose via optionlist. In this template I have created another userform (shows on document open) which is linked to the template's Bookmarks.
The problem is that when I create a new word file with the template, the userform shows up and everything works (I see the new document). But when I use my first userform with the optionlist to choose which template I want to use I never get to see the new document. It exist though cause when I close word it asks me to save document2....
Has anyone got an idea how to show this document when I have filled in the userform
Here is my code
'//code of first userform (refering to template)
Private Sub CommandButton1_Click()
Dim objWord As Word.Application
Dim objDoc As Word.Document
If optVoltijdsO.Value = True Then
Set objWord = New Word.Application
Set objDoc = objWord.Documents.Add("C:\Documents and Settings\444236354\Application Data\Microsoft\Templates\Voltijdse loopbaanonderbreking voor ouderschapsverlof.dot")
End If
If optHalftijdsO.Value = True Then
Set objWord = New Word.Application
Set objDoc = objWord.Documents.Add("C:\Documents and Settings\444236354\Application Data\Microsoft\Templates\Haltijdse loopbaanonderbreking voor ouderschapsverlof.dot")
End If
End Sub
'// code which creates new doc based on template
Private Sub cmdOK_Click()
Dim strAanvang As String
If optAanvang = True Then strAanvang = "AGP"
Application.ScreenUpdating = False
With ActiveDocument
.Bookmarks("Aanvang").Range.Text = txtAanvang.Value
.Bookmarks("Aanvraag").Range.Text = txtAanvraag.Value
End With
Application.ScreenUpdating = True
Unload Me
End Sub
I have deleted som Dims, Ifs and Bookmarks since they don't matter.
Thank you in advance