1 Attachment(s)
Help please - userform not coming up
Hi,
I'm verturing into my first attempts at some simple coding with userforms and have been followinf various examples and tutorials online. However my 'test' just refuses to display the userform I have created.
I have this in the userform (named MyForm) part of the project
Option Explicit
Private Sub cmdSubmit_Click()
FillBM "Test", txttest.Text
Unload Me
End Sub
Private Sub FillBM(strBMName As String, strValue As String)
Dim orng As Range
With ActiveDocument
Application.ScreenUpdating = False
On Error GoTo lbl_Exit
Set orng = .Bookmarks(strBMName).Range
orng.Text = strValue
orng.Bookmarks.Add strBMName
End With
Application.ScreenUpdating = True
lbl_Exit:
Set orng = Nothing
Exit Sub
End Sub
Private Sub cmdCancel_Click()
ActiveDocument.Close SaveChanges:=False
MyForm.Hide
End Sub
And this in the Module (named modMain)
Sub AutoNew()
Create_Reset_Variables
CallUF
lbl_Exit:
Exit Sub
End Sub
And this in the Thus Document part (although I also tried sticking it in the ModMain as well)
Option Explicit
Sub CallUF()
Dim oFrm As MyForm
Set oFrm = New MyForm
oFrm.Show
Unload oFrm
Set oFrm = Nothing
lbl_Exit:
Exit Sub
End Sub
The AutoNew works fine and creates a new document and the macro CallUf is there (and I can run in manually) but why won't it start automatically when I create a new doc from the template?
Any help would be appreciated
Thanks
Oh - here is the whole thing if it helps
Attachment 22670