PDA

View Full Version : [SOLVED:] microsoft word on/off botton to control VBA script



jo55
05-27-2015, 08:40 AM
hi,

i have this script:

Attribute VB_Name = "wordPerfetTypeJustification"


Sub ChangeJustification()
With ActiveDocument
.Compatibility(wdWPJustification) = True
End With
End Sub


i would like to make one on/off botton to control this VBA script (to change True/False) just like Bold/Italic/Under botton work
dont know if it needs a "IF" type of script added

thanks

gmayor
05-29-2015, 04:22 AM
Change the line to

.Compatibility(wdWPJustification) = Not .Compatibility(wdWPJustification)
That will toggle the value.

Providing a button on the ribbon that will reflect the status is an altogether more complex issue. I think Greg has it covered at http://gregmaxey.mvps.org/word_tip_pages/customize_ribbon_main.html

jo55
05-31-2015, 04:46 PM
thanks Gmayor, this is working now!!!!!!

is the botton supposed to be a click in click out styel, or only toggle the value witch is the current cases.

---------------------------------------

Sub Justification2()
With ActiveDocument
.Compatibility(wdWPJustification) = Not .Compatibility(wdWPJustification)
End With
End Sub

gmayor
05-31-2015, 08:36 PM
As I said, creating a click in/out button is far more complicated than the macro itself, but is covered in Greg's ribbon tutorials if you want to go that far. A simple button will do the job.

jo55
06-02-2015, 12:18 AM
thanks again gmayor :friends: