Images never paste in document as "inline"

A

AnneT

Hi,
Word2003. Tools.Options.Edit.PastePicturesAs - Inline with text.

I am trying to paste an image from the clipboard into a Word Document via
VBA. I have the setting set correctly under tools. It never pastes as
inline. After pasting, I always have to explicitly convert to inline shape.

Also, because it doesn't paste inline, if I am trying to set the image into
a table cell, the convert to inline shape sets the image in the correct row,
but always column 1, not column 2.

Any ideas of why I cannot paste inline? Two code snippets below. I am
running the code from Excel - trying to generate Word reports out of Excel,
hence the "wrdapp", "wrddoc", "wrdrange" references:

'Try to paste into row1, col2
wrdDoc.Tables(1).Cell(Row:=1, Column:=2).Range.Select
With wrdApp.Selection
.InsertAfter "hello" 'make sure selection is in the
right column
.PasteSpecial Placement:=wdInLine 'still doesn't work
End With
wrdDoc.Shapes(1).ConvertToInlineShape 'have to convert to inline, placed
r1c1

'try to paste into row2, col2
wrdDoc.Tables(1).Cell(Row:=2, Column:=2).Range.Select
wrdApp.Selection.PasteSpecial Placement:=wdInLine 'still doesn't
work
wrdDoc.Shapes(1).ConvertToInlineShape


'try to paste into 1st para
Set wrdrange = wrdDoc.Paragraphs.First.Range
With wrdDoc.Paragraphs(1).Range
.InsertAfter strEvent
.Paste 'doesn't paste inline even though
default set
End With
wrdDoc.Shapes(1).ConvertToInlineShape

The really strange part is even if i just open a new document, and select
paste, the image is not pasted inline.

What am I missing?

Thanks for your help
 
J

Jezebel

VBA's PasteSpecial doesn't refer to the setting under Tools > Options.

My guess is that you're running this code in Excel using CreateObject rather
than by adding a reference to the Word object library to your Excel VBA
project. As a consequence, Excel's VBA doesn't know the value of the
WdOLEPlacement constants.
 
A

AnneT

Thanks for responding. I do use the CreateObject method. Here is my
beginning code:

Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
'On Error GoTo Message
Set wrdDoc =
wrdApp.Documents.Open("c:\TheFundRaiserPlannerTemplates\zPurchaseReportTemplate.doc")


However, I have added Word to my Excel VBA reference library, so it should
recognize the Word constants.

Even more confusing, if I just open a completely new word document outside
of my application, the image is NOT pasted inline, although my settings
indicate that it should. I'm thinking that it's something within Word not
recognizing inline paste. I can convert the images, either manually or via
VBA to inline, but can't seem to paste an image inline. Any ideas?
 

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