Need assist for code to set crop settings for pic pasted from Exce

B

Brent E

Good afternoon,

I need to figure out VBA code to set "CropLeft, Cropbottom, CropTop, and
CropRight" property settings for a picture copied from Excel and pasted in
Word.
I use an Access module to control Excel and Word using object variables.

I use a object variable called OBJEWORD in an Access procedure to control
Word.
I can get Word to run fine and add a new document, I can get document to
paste pic fine from Excel, but if I try to set properties for picture in
Word, I keep getting an error and must debug.
I setup a macro in Word to make sure code is correct. That works fine, but
if I use that code from Word macro and paste to access module, and add
OBJEWORD in front of those commands, doesnt work.
These commads are from a word macro code that works:
Selection.InlineShapes(1).Fill.Visible = msoFalse
Selection.InlineShapes(1).Fill.Solid
Selection.InlineShapes(1).Fill.Transparency = 0#
Selection.InlineShapes(1).Line.Weight = 0.75
Selection.InlineShapes(1).Line.Transparency = 0#
Selection.InlineShapes(1).Line.Visible = msoFalse
Selection.InlineShapes(1).LockAspectRatio = msoTrue
Selection.InlineShapes(1).Height = 144#
Selection.InlineShapes(1).Width = 210.95
Selection.InlineShapes(1).PictureFormat.Brightness = 0.5
Selection.InlineShapes(1).PictureFormat.Contrast = 0.5
Selection.InlineShapes(1).PictureFormat.ColorType = msoPictureAutomatic
Selection.InlineShapes(1).PictureFormat.CropLeft = 0#
Selection.InlineShapes(1).PictureFormat.CropRight = 0#
Selection.InlineShapes(1).PictureFormat.CropTop = 0#
Selection.InlineShapes(1).PictureFormat.CropBottom = 0#
I added a OBJECT variable in front of these in my access module thinking I
could run these from access. Commands look like this
'OBJEWORD.Selection.InlineShapes(1).Fill.Solid
'OBJEWORD.Selection.InlineShapes(1).Fill.Transparency = 0#
'OBJEWORD.Selection.InlineShapes(1).Line.Weight = 0.75
'OBJEWORD.Selection.InlineShapes(1).Line.Transparency = 0#
'OBJEWORD.Selection.InlineShapes(1).Line.Visible = msoFalse
'OBJEWORD.Selection.InlineShapes(1).LockAspectRatio = msoFalse
'OBJEWORD.Selection.InlineShapes(1).Height = 344.15
'OBJEWORD.Selection.InlineShapes(1).Width = 540#
'OBJEWORD.Selection.InlineShapes(1).PictureFormat.Brightness = 0.5
'OBJEWORD.Selection.InlineShapes(1).PictureFormat.Contrast = 0.5
'OBJEWORD.Selection.InlineShapes(1).PictureFormat.ColorType =
msoPictureAutomatic
'OBJEWORD.Selection.InlineShapes(1).PictureFormat.CropLeft = 0#
'OBJEWORD.Selection.InlineShapes(1).PictureFormat.CropRight = 0#
'OBJEWORD.Selection.InlineShapes(1).PictureFormat.CropTop = 0#
'OBJEWORD.Selection.InlineShapes(1).PictureFormat.CropBottom = 0#
Also tried to use a with statement and no difference.

Anybody know a way I can set these properties for pic pasted in Word using
my object variable?
 
J

John Vinson

Good afternoon,

I need to figure out VBA code to set "CropLeft, Cropbottom, CropTop, and
CropRight" property settings for a picture copied from Excel and pasted in
Word.
I use an Access module to control Excel and Word using object variables.

Microsoft's vexing Help system has misled you into posting this
question in microsoft.public.ACCESS, which is for a different program
- Microsoft Access. I'd suggest you scroll down to a suitable Excel
newsgroup.


John W. Vinson[MVP]
 
A

Andi Mayer

Good afternoon,

I need to figure out VBA code to set "CropLeft, Cropbottom, CropTop, and
CropRight" property settings for a picture copied from Excel and pasted in
Word.
I use an Access module to control Excel and Word using object variables.

I use a object variable called OBJEWORD in an Access procedure to control
Word.
I can get Word to run fine and add a new document, I can get document to
paste pic fine from Excel, but if I try to set properties for picture in
Word, I keep getting an error and must debug.
I setup a macro in Word to make sure code is correct. That works fine, but
if I use that code from Word macro and paste to access module, and add
OBJEWORD in front of those commands, doesnt work.
These commads are from a word macro code that works:
Selection.InlineShapes(1).Fill.Visible = msoFalse
Selection.InlineShapes(1).Fill.Solid ..
..
..
'OBJEWORD.Selection.InlineShapes(1).PictureFormat.CropRight = 0#
'OBJEWORD.Selection.InlineShapes(1).PictureFormat.CropTop = 0#
'OBJEWORD.Selection.InlineShapes(1).PictureFormat.CropBottom = 0#
Also tried to use a with statement and no difference.

Anybody know a way I can set these properties for pic pasted in Word using
my object variable?


you should try with (not checked: only aircode!!!)

dim shape as object
Set aShape=objeword.InlineShape(1)


If you expect an answer to a personal mail, add the word "manfred" to the first 10 lines in the message
MW
 

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