set picture Width and Height with ActiveDocument.Shapes.AddPicture

  • Thread starter teddy b via OfficeKB.com
  • Start date
T

teddy b via OfficeKB.com

I try the script below at Word 2002 template file is works fine but not for
Word 97?
When run at Word 97, i ecounter an error and it close my Word. If i remove
the Width and Height then everthing are ok. Anyone can help?

Set myShape = ActiveDocument.Shapes.AddPicture(FileName:="C:\ImageFileName.
gif", LinkToFile:=False, Width:=155#, Height:=25#, Anchor:=.Paragraphs(1).
Range)

Thanks.
 
J

Jean-Guy Marcil

teddy b via OfficeKB.com was telling us:
teddy b via OfficeKB.com nous racontait que :
I try the script below at Word 2002 template file is works fine but
not for Word 97?
When run at Word 97, i ecounter an error and it close my Word. If i
remove the Width and Height then everthing are ok. Anyone can help?

Set myShape =
ActiveDocument.Shapes.AddPicture(FileName:="C:\ImageFileName. gif",
LinkToFile:=False, Width:=155#, Height:=25#, Anchor:=.Paragraphs(1).
Range)

I am not sure why you are seeing this behaviour (I have not coded for Word
97 in over 2 years)
Meanwhile, try this instead:

Set myShape = ActiveDocument.Shapes.AddPicture(FileName:="C:\ImageFileName.
gif", LinkToFile:=False, Anchor:=.Paragraphs(1).Range)
With myShape
.LockAspectRatio = msoFalse
.Width = 155
.Height = 25
End With



--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
T

teddy b via OfficeKB.com

Thanks.

But i need it work for both version cause some of my users still using Word
97.
In 97 has this Width, and Heigh for Shapes.AddPicture but why it not working?
I need to set both:

Set myShape = ActiveDocument.Shapes.AddPicture(FileName:="C:\ImageFileName.
gif", LinkToFile:=False, Width:=155, Height:=25, Anchor:=.Paragraphs(1).Range)


With myShape
.LockAspectRatio = msoFalse
.Width = 155
.Height = 25
End With

Please help. Thanks.

Jean-Guy Marcil said:
teddy b via OfficeKB.com was telling us:
teddy b via OfficeKB.com nous racontait que :
I try the script below at Word 2002 template file is works fine but
not for Word 97?
[quoted text clipped - 5 lines]
LinkToFile:=False, Width:=155#, Height:=25#, Anchor:=.Paragraphs(1).
Range)

I am not sure why you are seeing this behaviour (I have not coded for Word
97 in over 2 years)
Meanwhile, try this instead:

Set myShape = ActiveDocument.Shapes.AddPicture(FileName:="C:\ImageFileName.
gif", LinkToFile:=False, Anchor:=.Paragraphs(1).Range)
With myShape
.LockAspectRatio = msoFalse
.Width = 155
.Height = 25
End With
 
J

Jean-Guy Marcil

teddy b via OfficeKB.com was telling us:
teddy b via OfficeKB.com nous racontait que :
Thanks.

But i need it work for both version cause some of my users still
using Word
97.

What versions are yout alking about?
In 97 has this Width, and Heigh for Shapes.AddPicture but why it not
working? I need to set both:

Like I wrote earlier, I am not sure why it is not working. It works on my
machine.
The code you posted seems to be part of a With block. Can you post the
surrounding code?

Meanwhile, have you tried my suggestion?


--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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