Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-30-2019, 08:14 PM
~clover ~clover is offline Userform to output specific text Windows 10 Userform to output specific text Office 2013
Novice
Userform to output specific text
 
Join Date: May 2019
Posts: 2
~clover is on a distinguished road
Question Userform to output specific text

Hi all,

Working on a project for work, unfortunately new to VBA and kinda learning as I go. Searched all over today and have not been able to figure this out. I want to create a userform to have a dialog popup with a question and two command button options "yes" or "no" and depending on which option is selected, output specific text at a particular place in the document. Example: dialog box asks "Is the cow green?" options "yes" or "no" if yes is selected "the cow is green" is input into a specific section of the word document, if no is selected "the cow is not green" is input in the same section of the document. Could anyone point me in the right direction where I'm messing up with the code? (obviously this isn't the specific text, but to make things simple we'll use that for the example)
Thanks!!

CommandButton1_Click()

With ActiveDocument
.Bookmarks("Text1").Range _
.InsertBefore TextBox1
the cow is green
.Bookmarks("Text2").Range _
.InsertBefore TextBox2


the cow is not green
End With

UserForm1.Hide

End Sub
Reply With Quote
  #2  
Old 05-31-2019, 02:37 AM
gmayor's Avatar
gmayor gmayor is offline Userform to output specific text Windows 10 Userform to output specific text Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

See http://www.gmayor.com/Userform.htm and in particular the FillBM function then you need something like.

Code:
Private Sub CommandButton1_Click()
    With ActiveDocument
        If UCase(TextBox1.Text) = "YES" Then
            FillBM "Text1", "The cow is green"
        Else
            FillBM "Text1", "The cow is not green"
        End If
    End With
    Unload Me
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 06-01-2019, 07:04 AM
~clover ~clover is offline Userform to output specific text Windows 10 Userform to output specific text Office 2013
Novice
Userform to output specific text
 
Join Date: May 2019
Posts: 2
~clover is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
See http://www.gmayor.com/Userform.htm and in particular the FillBM function then you need something like.

Code:
Private Sub CommandButton1_Click()
    With ActiveDocument
        If UCase(TextBox1.Text) = "YES" Then
            FillBM "Text1", "The cow is green"
        Else
            FillBM "Text1", "The cow is not green"
        End If
    End With
    Unload Me
End Sub
This worked.. thanks so much!!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook Template: Trying to Output text and fields back2ict Outlook 0 07-03-2018 08:57 AM
Linking Specific text fields in PP to specific cells in an Excel table GWRW1964 PowerPoint 0 02-26-2018 07:37 AM
Userform to output specific text How do I output special character to a specific cell (x,y)? norwood Word VBA 2 01-31-2014 01:26 PM
How do I output text to a specific cell (x,y)? norwood Word VBA 2 01-31-2014 08:43 AM
Userform to output specific text Setting focus to specific word document from UserForm SaneMan Word VBA 5 04-01-2011 03:11 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:16 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft