Constant problem

J

Jan Kronsell

Hi NG!

Im trying to automate Word from Access and it works Ok, except for this
line:

wdApp.Selection.ParagraphFormat.Alignment = wdAlignParagraphRight

Apparently Access VBA will not recognize wdAlignParagraphRight as a word
constant, and think of it as a Variable.
I have set a reference to the Word 10.0 Object library.

If I declare it as a Variable in Access, it expects it to have a value. Do
you know how i can do this?

All I really want to do is to right aling one paragraph, then reset to left
alignment.

Regards
Jan
 
H

Helmut Weber

Hi Jan,
you may use 2 (integer) instead.

Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"
Word 97, NT 4.0
 
C

Can Altinbay

Helmut Weber said:
Hi Jan,
you may use 2 (integer) instead.

Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"
Word 97, NT 4.0

That's great, but the point of constants is that when Microsoft changes the
values, things will still work. This one may be relatively safe, but...
Are there any more general ways to solve the problem?
 
H

Helmut Weber

Hi,
if you use early binding, that is to set a reference
to the appropriate library, it should be possible
to use constants. I didn't understand, why this didn't
work from access, as Jan described it, so I recommended
this workaround. Maybe somebody else knows how big the
danger is of microsoft changing values of constants.
I regard it as a rather theoretical issue.

Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"
Word 97, NT4.0
 
J

Jezebel

You can refer to the constant as a property of the object that defines it.
If your project knows what 'Word' is (ie, you have a project reference to
MSWordX.olb) you can use

wdApp.Selection.ParagraphFormat.Alignment =
Word.wdParagraphAlignment.wdAlignParagraphRight
 
G

Guest

Try this:
Word.wdAlignParagraphRight
-----Original Message-----
Hi NG!

Im trying to automate Word from Access and it works Ok, except for this
line:

wdApp.Selection.ParagraphFormat.Alignment = wdAlignParagraphRight

Apparently Access VBA will not recognize
wdAlignParagraphRight as a word
 
B

Billy Chan

Try this:
Word.wdAlignParagraphRight

The wdAlignParagraphRight is part of Word, so Access
doesn't know about it.
-----Original Message-----
Hi NG!

Im trying to automate Word from Access and it works Ok, except for this
line:

wdApp.Selection.ParagraphFormat.Alignment = wdAlignParagraphRight

Apparently Access VBA will not recognize
wdAlignParagraphRight as a word
 

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