Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-22-2011, 04:26 AM
tinfanide tinfanide is offline Word VBA: How to create a command button and trigger a function? Windows 7 64bit Word VBA: How to create a command button and trigger a function? Office 2010 32bit
Expert
Word VBA: How to create a command button and trigger a function?
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default Word VBA: How to create a command button and trigger a function?

Code:
Private Sub CommandButton1_Click()

Selection.Font.Color = wdColorRed

End Sub
I couldn't link the command button with the below codes.
How can I create a command button to do the things below?

Code:
Selection.Font.Color = wdColorRed
    Selection.Font.Bold = wdToggle
    If Selection.Font.Underline = wdUnderlineNone Then
        Selection.Font.Underline = wdUnderlineSingle
    Else
        Selection.Font.Underline = wdUnderlineNone
    End If

Reply With Quote
  #2  
Old 11-30-2011, 04:22 AM
macropod's Avatar
macropod macropod is offline Word VBA: How to create a command button and trigger a function? Windows 7 64bit Word VBA: How to create a command button and trigger a function? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Tinfanide,

Try:
Code:
Private Sub CommandButton1_Click()
With Selection.Font
  .Color = wdColorRed
  .Bold = wdToggle
  If .Underline = wdUnderlineNone Then
    .Underline = wdUnderlineSingle
  Else
    .Underline = wdUnderlineNone
  End If
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 12-02-2011, 05:51 AM
tinfanide tinfanide is offline Word VBA: How to create a command button and trigger a function? Windows 7 64bit Word VBA: How to create a command button and trigger a function? Office 2010 32bit
Expert
Word VBA: How to create a command button and trigger a function?
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default

Yes, I see how. Thanks.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check Boxes and Command Buttons Micky P Word VBA 0 10-27-2011 01:06 AM
Word doc bug when closing from userform command button click macro Joe Patrick Word 1 07-05-2011 08:53 PM
Word VBA: How to create a command button and trigger a function? Launch macro sub after hitting "create pdf" button in word webharvest Word VBA 1 06-29-2011 04:56 PM
Desperatly need help in trigger animations quinn307 PowerPoint 0 03-27-2011 08:52 PM
Word VBA: How to create a command button and trigger a function? Command Button cksm4 Word VBA 7 02-27-2011 08:47 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:54 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