C
Clint Wagner
Hello, [please let me know if this is wrong group]
I have searched for the problem that I am having and I have found
similar references, but the fixes are correcting the minor issue that I
am having.
Problem: Getting Error 5101 after hitting "OK" on user input form.
Form Description: It's a basic fax UserForm (Name, Pages, Destination,
Fax No, Company, etc) that passes the characters from the UserForm onto
designated positions in the Word document.
In my first creation of this template, everything works fine after
filling out the form. The text and #'s are passed onto the document
perfectly. However, I found that I started getting Error 5101 when I
copied the code from my original project/templated for the creation of
my second project/template which is almost identical but with a differnt
caption for the UserForm . I am also noticing that the UserForm for the
second document (ProjectTemplate as it refers in VB pane) is referencing
the UserForm from my orignial template. I can tell this b/c each
UserForm has a different caption.
Let me know if you have any ideas or suggestions: (Below is pasted code)
Private Sub PB_Cancel_Click()
On Error GoTo PB_Cancel_Click_Error
Application.ScreenUpdating = False
Selection.GoTo What:=wdGoToBookmark, Name:="DocumentStart"
Application.ScreenUpdating = True
Unload Frm_Dialog
Exit Sub
PB_Cancel_Click_Error:
MsgBox "Error Number " & Err.Number & Chr$(13) & Chr$(10) &
Err.Description, vbOKOnly + vbCritical,
ActiveDocument.BuiltInDocumentProperties("Company") & " " &
ActiveDocument.BuiltInDocumentProperties("Title")
Application.ScreenUpdating = True
Unload Frm_Dialog
End Sub
Private Sub PB_OK_Click()
On Error GoTo PB_OK_Click_Error
Application.ScreenUpdating = False
'Insert To Field.
Selection.GoTo What:=wdGoToBookmark, Name:="DocumentStart"
Selection.InsertBefore Text:=TB_To.Text
'Insert Destination.
Selection.GoTo What:=wdGoToBookmark, Name:="Destination"
Selection.InsertBefore Text:=TB_Destination.Text
'Insert Company.
Selection.GoTo What:=wdGoToBookmark, Name:="Company"
Selection.InsertBefore Text:=TB_Company.Text
'Insert Pages.
Selection.GoTo What:=wdGoToBookmark, Name:="Pages"
Selection.InsertBefore Text:=TB_Pages.Text
'Insert From Field.
Selection.GoTo What:=wdGoToBookmark, Name:="From"
Selection.InsertBefore Text:=TB_From.Text
'Insert Sender Field.
Selection.GoTo What:=wdGoToBookmark, Name:="Sender"
Selection.InsertBefore Text:=TB_Sender.Text
'Insert Date.
Selection.GoTo What:=wdGoToBookmark, Name:="Date"
Selection.InsertBefore Text:=TB_Date.Text
'Insert Subject.
Selection.GoTo What:=wdGoToBookmark, Name:="Subject"
Selection.InsertBefore Text:=TB_Subject.Text
'*Position insertion point for user.
Selection.GoTo What:=wdGoToBookmark, Name:="DocumentEnd"
Application.ScreenUpdating = True
Unload Frm_Dialog
Exit Sub
PB_OK_Click_Error:
MsgBox "Error Number " & Err.Number & Chr$(13) & Chr$(10) &
Err.Description, vbOKOnly + vbCritical,
ActiveDocument.BuiltInDocumentProperties("Company") & " " &
ActiveDocument.BuiltInDocumentProperties("Title")
Application.ScreenUpdating = True
Unload Frm_Dialog
End Sub
Private Sub UserForm_Activate()
Frm_Dialog.Caption =
ActiveDocument.BuiltInDocumentProperties("Company") & " - " &
ActiveDocument.BuiltInDocumentProperties("Title")
TB_From = Application.UserName
TB_Date = Format(Date, "MMMM dd, yyyy")
End Sub
I have searched for the problem that I am having and I have found
similar references, but the fixes are correcting the minor issue that I
am having.
Problem: Getting Error 5101 after hitting "OK" on user input form.
Form Description: It's a basic fax UserForm (Name, Pages, Destination,
Fax No, Company, etc) that passes the characters from the UserForm onto
designated positions in the Word document.
In my first creation of this template, everything works fine after
filling out the form. The text and #'s are passed onto the document
perfectly. However, I found that I started getting Error 5101 when I
copied the code from my original project/templated for the creation of
my second project/template which is almost identical but with a differnt
caption for the UserForm . I am also noticing that the UserForm for the
second document (ProjectTemplate as it refers in VB pane) is referencing
the UserForm from my orignial template. I can tell this b/c each
UserForm has a different caption.
Let me know if you have any ideas or suggestions: (Below is pasted code)
Private Sub PB_Cancel_Click()
On Error GoTo PB_Cancel_Click_Error
Application.ScreenUpdating = False
Selection.GoTo What:=wdGoToBookmark, Name:="DocumentStart"
Application.ScreenUpdating = True
Unload Frm_Dialog
Exit Sub
PB_Cancel_Click_Error:
MsgBox "Error Number " & Err.Number & Chr$(13) & Chr$(10) &
Err.Description, vbOKOnly + vbCritical,
ActiveDocument.BuiltInDocumentProperties("Company") & " " &
ActiveDocument.BuiltInDocumentProperties("Title")
Application.ScreenUpdating = True
Unload Frm_Dialog
End Sub
Private Sub PB_OK_Click()
On Error GoTo PB_OK_Click_Error
Application.ScreenUpdating = False
'Insert To Field.
Selection.GoTo What:=wdGoToBookmark, Name:="DocumentStart"
Selection.InsertBefore Text:=TB_To.Text
'Insert Destination.
Selection.GoTo What:=wdGoToBookmark, Name:="Destination"
Selection.InsertBefore Text:=TB_Destination.Text
'Insert Company.
Selection.GoTo What:=wdGoToBookmark, Name:="Company"
Selection.InsertBefore Text:=TB_Company.Text
'Insert Pages.
Selection.GoTo What:=wdGoToBookmark, Name:="Pages"
Selection.InsertBefore Text:=TB_Pages.Text
'Insert From Field.
Selection.GoTo What:=wdGoToBookmark, Name:="From"
Selection.InsertBefore Text:=TB_From.Text
'Insert Sender Field.
Selection.GoTo What:=wdGoToBookmark, Name:="Sender"
Selection.InsertBefore Text:=TB_Sender.Text
'Insert Date.
Selection.GoTo What:=wdGoToBookmark, Name:="Date"
Selection.InsertBefore Text:=TB_Date.Text
'Insert Subject.
Selection.GoTo What:=wdGoToBookmark, Name:="Subject"
Selection.InsertBefore Text:=TB_Subject.Text
'*Position insertion point for user.
Selection.GoTo What:=wdGoToBookmark, Name:="DocumentEnd"
Application.ScreenUpdating = True
Unload Frm_Dialog
Exit Sub
PB_OK_Click_Error:
MsgBox "Error Number " & Err.Number & Chr$(13) & Chr$(10) &
Err.Description, vbOKOnly + vbCritical,
ActiveDocument.BuiltInDocumentProperties("Company") & " " &
ActiveDocument.BuiltInDocumentProperties("Title")
Application.ScreenUpdating = True
Unload Frm_Dialog
End Sub
Private Sub UserForm_Activate()
Frm_Dialog.Caption =
ActiveDocument.BuiltInDocumentProperties("Company") & " - " &
ActiveDocument.BuiltInDocumentProperties("Title")
TB_From = Application.UserName
TB_Date = Format(Date, "MMMM dd, yyyy")
End Sub