none
TypeText issues RRS feed

  • Question

  • I have code where a user is prompted to completed fields.  If they enter in a cc: then it formats as such:

    XXX -- person's name

    cc:

    If you do not enter in anything into the cc: then the cc: appears by itself.  The clode is below.  How do I get it to (1) if entered, then always place the person who is being cc'd next to it; and (2) if nothing is there, then do not include the cc'd at all.

    Public Sub StateClosing()
          On Error GoTo ErrHandler
          
        With Selection
            .ParagraphFormat.TabStops.Add Position:=InchesToPoints(2.5), _
                Alignment:=wdAlignTabLeft, Leader:=wdTabLeaderSpaces
            .ParagraphFormat.TabStops.Add Position:=InchesToPoints(4), _
                Alignment:=wdAlignTabLeft, Leader:=wdTabLeaderSpaces
            .TypeText Text:=gstring1 & vbCrLf & vbCrLf
            .TypeText Text:=gstring2 & vbTab & "Accepted by" & vbCrLf
                    
            .ParagraphFormat.SpaceBefore = 6: .Font.Bold = True
            
            .TypeText Text:=mstrOffice
                    
            .Font.Bold = False
            .TypeText Text:=vbTab & "Authorized signature:" & vbTab
            .Font.Underline = wdUnderlineSingle
            .TypeText Text:=vbTab & vbTab & vbTab & vbTab
            .Font.Underline = wdUnderlineNone
            .TypeText Text:=vbCrLf
            
            .ParagraphFormat.SpaceBefore = 0
            .TypeText Text:=vbCrLf
            .TypeText Text:=vbTab & "By:" & vbTab
            .Font.Underline = wdUnderlineSingle
            .TypeText Text:=vbTab & vbTab & vbTab & vbTab
            .Font.Underline = wdUnderlineNone
            .TypeText Text:=vbCrLf & vbCrLf
            .TypeText Text:=InputBox("Enter the author's name:", , "John Doe") & vbTab
            .TypeText Text:="Title:" & vbTab
            .Font.Underline = wdUnderlineSingle
            .TypeText Text:=vbTab & vbTab & vbTab & vbTab
            .Font.Underline = wdUnderlineNone
            .TypeText Text:=vbCrLf & InputBox("Enter the author's title:") & vbCrLf
            .TypeText Text:=vbTab & "Date:" & vbTab
            .Font.Underline = wdUnderlineSingle
            .TypeText Text:=vbTab & vbTab & vbTab & vbTab
            .Font.Underline = wdUnderlineNone
            .TypeText Text:=vbCrLf
            .TypeText Text:=InputBox("Enter initials/valid proposal signoff/WP initials.") & _
                vbCrLf
             .TypeText Text:=InputBox("Enter cc:", , "")
             If .Text <> "" And .Text <> "" Then .Text = vbCrLf & "cc: " & .Text & vbCrLf
            .ParagraphFormat.TabStops.ClearAll
        End With
        Exit Sub


    peonysmiles

    Tuesday, October 30, 2012 4:01 PM

Answers

  • Change the lines

             .TypeText Text:=InputBox("Enter cc:", , "")
             If .Text <> "" And .Text <> "" Then .Text = vbCrLf & "cc: " & .Text & vbCrLf

    to

            Dim strCC As String
            strCC = Trim(InputBox("Enter cc:"))
            If styrCC <> "" Then
                .TypeText Text:=vbCrLf & "cc: " & strCC & vbCrLf
            End If


    Regards, Hans Vogelaar

    • Marked as answer by fjaconda199 Tuesday, October 30, 2012 9:34 PM
    Tuesday, October 30, 2012 9:20 PM

All replies

  • Change the lines

             .TypeText Text:=InputBox("Enter cc:", , "")
             If .Text <> "" And .Text <> "" Then .Text = vbCrLf & "cc: " & .Text & vbCrLf

    to

            Dim strCC As String
            strCC = Trim(InputBox("Enter cc:"))
            If styrCC <> "" Then
                .TypeText Text:=vbCrLf & "cc: " & strCC & vbCrLf
            End If


    Regards, Hans Vogelaar

    • Marked as answer by fjaconda199 Tuesday, October 30, 2012 9:34 PM
    Tuesday, October 30, 2012 9:20 PM
  • Thanks, worked like a charm.

    peonysmiles

    Tuesday, October 30, 2012 9:35 PM