Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Same macro acts different

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello all toghether,

I wrote a macro to control useractions.
Only in case the user selected the Headingstyle "Standard", he is able to use the Bold-Button.
I've done the Basics with the Macro-Recorder, but I don't remeber the details. It works all the time.
Doesn't a Macro do the same, wether I use the Macro-Recorder or not?
If I change the Macroname or do the same with the Italic-Button, it doesn't work any more.
It only works for one Klick, if I start the Macro manually.

Sub Fett()
'
' Fett Makro
' Makro aufgezeichnet am 31.01.02 von Thorsten Weiß
'
If Selection.Style = ActiveDocument.Styles("Standard") Then
With Selection.Font
.Bold = wdToggle
'.Italic = wdToggle
End With
Else: With Selection.Font
.Bold = Selection.Font.Bold
'.Italic = Selection.Font.Italic
MsgBox "Nicht möglich, da Überschriften nicht editiert werden sollen", 64
End With
End If
End Sub


Thanx for your help
 
It is not exactly clear what the intention is but it seems like you want a button to toggle Bold on and off. The problem is that wdToggle is never assigned a value and so returns false all the time.

Try setting

wdToggle = Selection.Font.Bold

before starting the If Then ... Else condition.

AC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top