Paragraph Alignment property type

J

Jay

I'm using a Sub to set the paragraphs alignment to (eg) Justified. I
get a "Automation type not supported in Visual Basic" error on the
first line (beginning with"Sub") of the following code. I'm using Word
97. How do I fix this?

Sub SetStyle(Align As WdParagraphAlignment)
ActiveDocument.Styles("Normal").ParagraphFormat.Alignment = Align
End Sub
 
H

Helmut Weber

Hi Jay,

"WdParagraphAlignment" is not a data type
and align is a reseved word, a term VBA uses,
though doesn't do no harm here.
Sub SetStyle(Align As WdParagraphAlignment)
ActiveDocument.Styles("Normal").ParagraphFormat.Alignment = Align
End Sub


Sub SetStyle(lngAlign As Long)
ActiveDocument.Styles("Normal").ParagraphFormat.Alignment = lngAlign
End Sub

Sub test865()
Call SetStyle(wdAlignParagraphRight)
End Sub


Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
J

Jay

Thanks Helmut,

If I highlight the "Selection.ParagraphFormat.Alignment", right-click
on it and choose "Quick Info" from the pop-up menu, the tool tip (or
whatever it's called) displays "Alignment As WdParagraphAlignment". Is
this a mistake in the VBA tool tip?

Jay
 
H

Helmut Weber

Hi Jay,

don't know what to say.

In a way, as the help accepts whatever you typed in that place
and offers it as a data type.
It seems, it is hoping you have defined that particular data type.

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

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