Error 5946 in automating word

M

MaGi

Hi,
I try to automate WordXP from AccessXP (german version).
Most works fine, but when try to assign a style to a paragraph I get the
error 5946:
'NameLocal' is not a reference property. (in german: 'NameProperty' ist
keine Referenzeigenschaft.)
The source code in Access VBA is as following:

Dim objDoc As Word.Document, objWord As Word.Application, objRange As
Word.Range
Dim oParagr As Word.Paragraph, oStyle As Word.Style
....
Set objDoc = objWord.Documents.Add(Template:=gsGetTemplate, Visible:=True)
....
Set oParagr = objRange.Paragraphs.Add
oParagr.Range.Select
Set oStyle = objDoc.Styles("Standard")
Set oParagr.Range.Style = oStyle <---- here the error occurs

Please help me.
Thanks in advance
 
T

Tom Winter

Do not use SET when setting the style, even though you're using a style
object. I believe this:

oRange.Style = oStyle

actually works out to be:

oRange.Style.NameLocal = oStyle.NameLocal

since NameLocal is the default property of the Style object
 

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