Gmayor,
Sorry about that. I was trying to catch all the details….guess I missed that mark.
The checkboxes on the Word doc are ActiveX.
Here is the process that I am trying to achieve, followed by a better copy of the code I am using:
User makes selection of what Material Sheet they want printed (Mat1, Mat2, Mat3) via option button on the main userform; a non-selection is also an option
User selects “Print” button on main userform
Here is the code for the main userform:
Public Sub FindAndReplace_MaterialsChecklist()
Dim wrdApp As Object
Dim wrdNNDF As Object
Dim FindWhat, ReplaceWith
Dim FindWhat1, ReplaceWith1
Dim i As Integer
Dim j As Integer
Set wrdApp = CreateObject("Word.Application")
Set wrdNNDF = wrdApp.Documents.Open("C:\Materials\MATChecklist.docm)
FindWhat = Array("XXX", "YYY", "ZZZ", "WWW")
ReplaceWith = Array(tbox_Title.Text, tbox_JO1.Text, tbox_JO2.Text, tbox_PackNum.Text)
FindWhat1 = Array("AAA", "BBB", "CCC", "DDD", "EEE", "FFF", "GGG", "HHH", "III", "JJJ", "KKK", "LLL", "MMM", "NNN", "PPP")
ReplaceWith1 = Array(tbox_Ref1.Text, tbox_Ref2.Text, tbox_Ref3.Text, tbox_Ref4.Text, tbox_Ref5.Text, tbox_Ref6.Text, tbox_Ref7.Text, tbox_Ref8.Text, tbox_Ref9.Text, tbox_Ref10.Text, tbox_Ref11.Text, tbox_Ref12.Text, tbox_Ref13.Text, tbox_Ref14.Text, tbox_Ref15.Text)
wrdNNDF.Activate
wrdApp.Selection.Find.ClearFormatting
wrdApp.Selection.Find.Replacement.ClearFormatting
For i = 0 To 3
With wrdApp.Selection.Find
.Text = FindWhat(i)
.Replacement.Text = ReplaceWith(i)
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
wrdApp.Selection.Find.Execute Replace:=wdReplaceAll
Next i
For j = 0 To 14
With wrdApp.Selection.Find
.Text = FindWhat1(j)
.Replacement.Text = ReplaceWith1(j)
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
wrdApp.Selection.Find.Execute Replace:=wdReplaceAll
Next j
With wrdNNDF
.Activate
If ob_Mat1_Y.Value = True Or ob_Mat2_Y.Value = True Or ob_Mat3_Y.Value = True Then
UF_MatStatSht.Show
End if
wrdNNDF.PrintOut
wrdNNDF.Close SaveChanges:=wdDoNotSaveChanges
End With
wrdApp.Quit
End Sub
The user then makes option button selections on the second userform "UF_MatStatSht" and clicks the Continue button
Public Sub btn_Continue_Click()
If optbut_Order_Y.Value = True Then
.cb_DOC_List.Value = True
End If
If optbut_Order_N.Value = True Then
.cb_DOC_NA.Value = True
End If
If optbut_Trigger_Y.Value = True Then
.cb_DOC_TRIGGER_Y.Value = True
End If
If optbut_Trigger_N.Value = True Then
.cb_DOC_TRIGGER_N.Value = True
End If
End Sub
the ".cb........." objects are on the ActiveX checkboxes in the Word document, opened from the main userform.
I want the user selected options from the main and second userform to transfer to the Word doc, print, then close the doc without changes.
I hope that is better. Please let me know if you require more info.
Thanks again.
Chunk