Insert Formatted Text
I get unusual requests! I built a Word Template for my friend to construct his philatelic exhibit. The problem was that he already has hundreds of pages built, each one is a separate document.The revised idea is to have a pop-up dialog that allows his to insert his text in each page.
The dialog box has examples of the 2 colors that the text should be.
Private Sub cmdCancel_Click()
Unload usrFormatHeadings
usrFormatHeadings.Hide
End Sub
Private Sub cmdDoIt_Click()
On Error GoTo cmdDoIt_Click_Error
usrFormatHeadings.Hide
If optLevel1 = True Then
RunInsertTop
Else
RunInsertLower
End If
On Error GoTo 0
Exit Sub
cmdDoIt_Click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description _
& ") in procedure cmdDoIt_Click of Form usrFormatHeadings"
End Sub
Sub OpenBox()
usrFormatHeadings.Show
Unload usrFormatHeadings
End Sub
Sub RunInsertTop()
Selection.Font.Size = 16
Selection.Font.ColorIndex = wdDarkBlue
Selection.Font.Bold = True
Selection.ParagraphFormat.TabStops.Add Position:=InchesToPoints(7.0), _
Alignment:=wdAlignTabRight, Leader:=wdTabLeaderSpaces
Selection.TypeText Text:=usrFormatHeadings.txtTopLeft & vbTab
Selection.EndKey
Selection.Font.Size = 14
Selection.Font.Bold = True
Selection.Font.ColorIndex = wdDarkBlue
Selection.TypeText Text:=usrFormatHeadings.txtTopRight
Selection.Font.Bold = False
Selection.Font.ColorIndex = wdBlack
Selection.Font.Size = 11
Selection.InsertParagraph
Selection.MoveDown
End Sub
Sub RunInsertLower()
usrFormatHeadings.Hide
Selection.Font.Size = 16
Selection.Font.ColorIndex = wdBlue
Selection.Font.Bold = True
Selection.ParagraphFormat.TabStops.Add Position:=InchesToPoints(7.0), _
Alignment:=wdAlignTabRight, Leader:=wdTabLeaderSpaces
Selection.TypeText Text:=usrFormatHeadings.txtSubLeft & vbTab
Selection.EndKey
Selection.Font.Size = 14
Selection.Font.Bold = True
Selection.Font.ColorIndex = wdBlue
Selection.TypeText Text:=usrFormatHeadings.txtSubRight
Selection.Font.Bold = False
Selection.Font.ColorIndex = wdBlack
Selection.Font.Size = 11
Selection.InsertParagraph
Selection.MoveDown
End Sub
There were several issues:
- I had not programmed anything in Word in years
- My friend’s computer was corrupted and would not hold the settings
- The syntax was so much different form Excel and Access (thanks to the guys at Windows Secrets for putting up with my questions)
- My friend kept changing his mind about what he really wanted and what color it should be.
|