FormatPicture in Word.Basic API does not work in Word 2007

L

Leonid N

We have a problem in Word 2007 with our application using Word.Basic COM. I
created a small VBscript demonstrating the problem:

Set WordObj = CreateObject("Word.Basic")
WordObj.FileNewDefault()
WordObj.AppShow()
WordObj.insert("Some text")
WordObj.InsertPicture "some picture file",0,0
WordObj.CharLeft 1,1
WordObj.FormatPicture 0, 0, 0, 0, 0, 50, 50, 0, 0
Set WordObj = Nothing

The script works fine with Word 2003 but generates error:

test.vbs(7, 1) Microsoft Word: The FormatPicture command is not available
because the current selection is not a graphic.

with Word 2007.

Any idea why this happens and how to bypass the problem?

Rgds, Leonid
 
L

Leonid N

I've found a reasonable bypass for the problem: the function works when Word
2007 works in compatibility mode, so adding line:

WordObj.FileSaveAs "c:\Doc1.doc", 0

after:

WordObj.FileNewDefault()



helps (of course name of file can be adjusted, but extension should be .doc,
which causes Word to switch itself to compatibility mode)
 

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