how do a toggle in Word 6?

L

Larry

This macro in Word 97 toggles the blue screen off and on:

Sub BlueScreenToggle()
Options.BlueScreen = Not (Options.BlueScreen)
End Sub

What would be the equivalent code for Word 6?

Thanks,
Larry
 
K

Klaus Linke

Larry said:
This macro in Word 97 toggles the blue screen off and on:

Sub BlueScreenToggle()
Options.BlueScreen = Not (Options.BlueScreen)
End Sub

What would be the equivalent code for Word 6?


Hi Larry,

It's been a couple of years that I wrote my last WordBasic macro, but it
should be

Dim Dlg As ToolsOptionsGeneral
GetCurValues Dlg
Dlg.BlueScreen = Abs(Dlg.BlueScreen - 1)
ToolsOptionsGeneral Dlg

.... I hope. Had to translate from the German WordBasic.

ToolsOptionsGeneral.BlueScreen was 1 for "True" and 0 for "False".
Usually, True corresponds to -1.
Thus the clumsy calculation: Abs(0-1)=1, Abs(1-1)=0.
You could devise several expressions to get around that... say
Dlg.BlueScreen = - Not(- Abs(Dlg.BlueScreen)) would work, too.

Klaus
 
L

Larry

I'll try it when I get to the other computer later, but from what you
said it looks kind of doubtful, Klaus. :)

Is a toggle in Word 6 realy so much more complicated than in Word 97?

Larry
 
K

Klaus Linke

Is a toggle in Word 6 realy so much more complicated than in Word 97?

WordBasic didn't have a Boolean data type, and used a lot of "magic numbers"
instead od wdConstants.

But I wouldn't call 3 lines of code "much more complicated".
If you think it's hard to read, you could write a bit more of code, and
comment it:

Dim Dlg As ToolsOptionsGeneral
GetCurValues Dlg
' Toggle BlueScreen between 0 and 1:
Select case Dlg.BlueScreen
Case 0
Dlg.BlueScreen = 1
Case 1
Dlg.BlueScreen = 0
End Select
ToolsOptionsGeneral Dlg
 
L

Larry

Klaus,

I'm trying it in Word 97 since I heard that Word 6 macros work in word
97. (I don't have the Word 6 computer here in my home) . But I'm
running into a lot of error messages.

I rewrote the Dim lines for the Dlg and that got me through that. But
now I'm stuck at GetCurValues Dlg. Also, what does that line mean?

Dim Dlg As Dialog
'Set Dlg = wdDialogToolsOptionsGeneral
Set Dlg = ToolsOptionsGeneral
'Dim Dlg As ToolsOptionsGeneral


GetCurValues Dlg
' Toggle BlueScreen between 0 and 1:
Select Case Dlg.BlueScreen
Case 0
Dlg.BlueScreen = 1
Case 1
Dlg.BlueScreen = 0
End Select
ToolsOptionsGeneral Dlg

Thanks,
Larry
 
K

Klaus Linke

Hi Larry,
I'm trying it in Word 97 since I heard that Word 6 macros work in
word 97. (I don't have the Word 6 computer here in my home) .

Word used WordBasic up to Word95.
Word97 uses VBA.

You can still run WordBasic code in Word97/2000/2002/2003, but you'll have
to make some changes (not that running WordBasic code makes much sense in
most cases...):

Dim dlg As Object
Set dlg = WordBasic.DialogRecord.ToolsOptionsGeneral(False)

WordBasic.CurValues.ToolsOptionsGeneral dlg

' Toggle BlueScreen between 0 and 1:
Select Case dlg.BlueScreen
Case 0
dlg.BlueScreen = 1
Case 1
dlg.BlueScreen = 0
End Select
WordBasic.ToolsOptionsGeneral dlg

Greetings,
Klaus
 
L

Larry

Ahh, I thought any Word 6 macro would run in Word 97 "as is". Anyway,
now I've got to try out the earlier one you gave me on the Word 6
computer. Will let you know how it works. Thanks.

Larry
 
L

Larry

Thanks Klaus. I just got around to trying the code on my friend's
laptop, and it works. I didn't have to tweak it or anything.

Larry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top