If statement

A

Angie M.

Hello,

I'm using Word 2003. I have two macros, both copy the styles from one
template into the current document and then one of the macros makes the
styles fully justified. They are part of a form so they run conditionally
when the user clicks OK. Problem is, I can't get just the first macro to
run, it always runs the MakeFull part of it, so no matter what I get full
alignment. After reading VBA help I tried switching statements after "then"
to the next line but I'm not having success. Any help would be appreciated!

Sub btnOK_Click()

If opt1 Then
Call NumOut1
End If


If opt1 And optFull Then
Call NumOut1
Call MakeFull
End If


The macros that are being called don't seem to be the problem but here they
are:

Sub NumOut1()

ActiveDocument.CopyStylesFromTemplate Template:= _
"c:\Numbering\Style Sheets\#1 Style Sheet.dot"
CommandBars("Numbering and Styles").Visible = True

End Sub

Sub MakeFull()

With ActiveDocument

.Styles("BodyTextDbl").ParagraphFormat.Alignment = wdAlignParagraphJustify
.Styles("Normal").ParagraphFormat.Alignment = wdAlignParagraphJustify
end with
end sub

THANKS
 
D

Doug Robbins - Word MVP

Are you sure that the style is not defined with full justification in the
first place.

What happens if you comment out the Call MakeFull from the btnOK_Click
event?


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
A

Angie M.

Thanks for responding. I checked the style sheet, it is left and not full.
I commented it out and the results are still justified. I have 25 different
style sheets that can be selected with a Left or Full option so I have 25
macros like this:



If opt2 Then Call NumOut2
If opt2 And optFull Then Call NumOut2
Call MakeFull


If opt3 Then Call NumOut3
If opt3 And optFull Then Call NumOut3
Call MakeFull

and so forth. Somehow this is running the makefull. I guess if my If
statement was wrong you would have noticed.

I need some VBA help on a paid consulting basis. Would you be available and
can I contact you? Thanks
 
A

Angie M.

I think I figured this out, I didn't have "= true" and it seems to be working
now:

If opt1 = True Then
Call NumOut1
End If


If opt1 = True And optFull = True Then
Call NumOut1
Call MakeFull
End If

I still need paid consulting help on a variety of things. Thanks for your
time, I will check this tomorrow for your reply.
 
D

Doug Robbins - Word MVP

Hi Angie,

While .Value is the default property for a checkbox, it is considered bad
practice to rely on the default, perhaps, because the default could change.

Therefore, it is better to use:

If opt1.Value = True Then
Call NumOut1
End If


If opt1.Value = True And optFull.Value = True Then
Call NumOut1
Call MakeFull
End If


You can contact me by deleting the uppercase letters from my address.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
A

Angie M.

Worked great, thank you.

Doug Robbins - Word MVP said:
Hi Angie,

While .Value is the default property for a checkbox, it is considered bad
practice to rely on the default, perhaps, because the default could change.

Therefore, it is better to use:

If opt1.Value = True Then
Call NumOut1
End If


If opt1.Value = True And optFull.Value = True Then
Call NumOut1
Call MakeFull
End If


You can contact me by deleting the uppercase letters from my address.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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