Consulting

Results 1 to 6 of 6

Thread: Inserting text from VBA textbox into part of a string

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Newbie
    Joined
    Nov 2022
    Posts
    3
    Location

    Question Inserting text from VBA textbox into part of a string

    Hi there, I'm new to VBA and hoping someone could help, if this might even be possible.

    A date will be manually added by the user into TEXTBOX1.

    .Bookmarks("BOOKMARK1").Range _
    .InsertBefore TEXTBOX1

    I have option buttons for the user to select which will place specific text and formatting (depending on the button selected) into the document as follows:

    Private Sub OptionButton2_Click()
    If Me.OptionButton2.Value = True Then
       Set oRng = ActiveDocument.Bookmarks("BOOKMARK2").Range
       oRng.Text = "EXAMPLE SENTENCE 1" & Chr(11) & Chr(9) & _
                          "EXAMPLE SENTENCE 2" & Chr(11) & _
                          "EXAMPLE SENTENCE 3" & vbNewLine & " "
       ActiveDocument.Bookmarks.Add "BOOKMARK2", oRng
      End If
    End Sub
    I am trying to get the date that has been entered in TEXTBOX1 to appear at the end of the sentence of EXAMPLE SENTENCE 2. Can anybody please help with this? Thank you!
    Last edited by Aussiebear; 12-02-2022 at 05:35 AM. Reason: Added code tags to supplied code

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •