Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Word 2007 macro to insert picture and word wrap

406 views
Skip to first unread message

charia

unread,
Nov 11, 2008, 2:01:02 PM11/11/08
to
Hi, When i insert a picture in a word document, i want to make a macro which
will select the picture, go to 'picture tools' -> 'format' -> 'text wrapping'
-> 'through'. But when i am recording the macro the 'arrange' portion of
'format' is all grey and i can not select anything. How do i create a macro
to do this. thanks

Doug Robbins - Word MVP

unread,
Nov 13, 2008, 1:13:37 AM11/13/08
to
Use

Dim ashape As Shape
Set ashape = ActiveDocument.Shapes.AddPicture(FileName, LinktoFile,
SaveWithDocument, Left, Top, Width, Height, Anchor)
ashape.WrapFormat.Type = wdWrapThrough

Check out the Shapes.AddPicture method in the Visual Basic Help file for
information on all of the terms within the parentheses.
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"charia" <cha...@discussions.microsoft.com> wrote in message
news:8305BE3F-3531-4F08...@microsoft.com...

andrewwalker

unread,
Nov 10, 2009, 2:24:10 AM11/10/09
to

Hey everyone,

I am trying to create an email signature that pulls all it's information from Active Directory. This is working fine but I also have an image in the signature and I need to change the wrapping to 'Square'.

Basically I want all of the signature text to appear to the right of the image (which it does when set to Square).

I am currently using the below but it is not changing the wrapping..

Set objShape = objSelection.InlineShapes.AddPicture("C:\image002.jpg, LinkToFile:=False, SaveWithDocument:=True")
Set objShape = objSelection.InlineShapes(1).ConvertToShape
objShape.WrapFormat.Type = wdWrapSquare

I did manage to get this to work within Word 2007 but not with Outlook.

Any help would be greatly appreciated.

Thanks in advance

Doug Robbins - Word MVP wrote:

UseDim ashape As ShapeSet ashape = ActiveDocument.Shapes.
13-Nov-08

Use

Dim ashape As Shape
Set ashape = ActiveDocument.Shapes.AddPicture(FileName, LinktoFile,
SaveWithDocument, Left, Top, Width, Height, Anchor)
ashape.WrapFormat.Type = wdWrapThrough

Check out the Shapes.AddPicture method in the Visual Basic Help file for
information on all of the terms within the parentheses.
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"charia" <cha...@discussions.microsoft.com> wrote in message
news:8305BE3F-3531-4F08...@microsoft.com...

Previous Posts In This Thread:

On 11 November 2008 14:01
chari wrote:

Word 2007 macro to insert picture and word wrap


Hi, When i insert a picture in a word document, i want to make a macro which
will select the picture, go to 'picture tools' -> 'format' -> 'text wrapping'
-> 'through'. But when i am recording the macro the 'arrange' portion of
'format' is all grey and i can not select anything. How do i create a macro
to do this. thanks

On 13 November 2008 01:13
Doug Robbins - Word MVP wrote:

UseDim ashape As ShapeSet ashape = ActiveDocument.Shapes.
Use

Dim ashape As Shape
Set ashape = ActiveDocument.Shapes.AddPicture(FileName, LinktoFile,
SaveWithDocument, Left, Top, Width, Height, Anchor)
ashape.WrapFormat.Type = wdWrapThrough

Check out the Shapes.AddPicture method in the Visual Basic Help file for
information on all of the terms within the parentheses.
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"charia" <cha...@discussions.microsoft.com> wrote in message
news:8305BE3F-3531-4F08...@microsoft.com...

EggHeadCafe - Software Developer Portal of Choice
Build An XML-Safe DES Crypto Library in VB.NET
http://www.eggheadcafe.com/tutorials/aspnet/8247991f-5091-40e6-abc3-36c58ba19ec9/build-an-xmlsafe-des-cry.aspx

andrewwalker

unread,
Nov 10, 2009, 2:26:17 AM11/10/09
to
Hey everyone,

I am trying to create an email signature that pulls all it's information from Active Directory. This is working fine but I also have an image in the signature and I need to change the wrapping to 'Square'.

Basically I want all of the signature text to appear to the right of the image (which it does when set to Square).

I am currently using the below but it is not changing the wrapping..

Set objShape = objSelection.InlineShapes.AddPicture("C:\image002.jpg, LinkToFile:=False, SaveWithDocument:=True")
Set objShape = objSelection.InlineShapes(1).ConvertToShape
objShape.WrapFormat.Type = wdWrapSquare

I did manage to get this to work within Word 2007 but not with Outlook.

Any help would be greatly appreciated.

Thanks in advance

Doug Robbins - Word MVP wrote:

UseDim ashape As ShapeSet ashape = ActiveDocument.Shapes.
13-Nov-08

Use

Dim ashape As Shape
Set ashape = ActiveDocument.Shapes.AddPicture(FileName, LinktoFile,
SaveWithDocument, Left, Top, Width, Height, Anchor)
ashape.WrapFormat.Type = wdWrapThrough

Check out the Shapes.AddPicture method in the Visual Basic Help file for
information on all of the terms within the parentheses.
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"charia" <cha...@discussions.microsoft.com> wrote in message
news:8305BE3F-3531-4F08...@microsoft.com...

Previous Posts In This Thread:

On 11 November 2008 14:01
chari wrote:

Word 2007 macro to insert picture and word wrap

Hi, When i insert a picture in a word document, i want to make a macro which
will select the picture, go to 'picture tools' -> 'format' -> 'text wrapping'
-> 'through'. But when i am recording the macro the 'arrange' portion of
'format' is all grey and i can not select anything. How do i create a macro
to do this. thanks

On 13 November 2008 01:13


Doug Robbins - Word MVP wrote:

UseDim ashape As ShapeSet ashape = ActiveDocument.Shapes.

Use

Dim ashape As Shape
Set ashape = ActiveDocument.Shapes.AddPicture(FileName, LinktoFile,
SaveWithDocument, Left, Top, Width, Height, Anchor)
ashape.WrapFormat.Type = wdWrapThrough

Check out the Shapes.AddPicture method in the Visual Basic Help file for
information on all of the terms within the parentheses.
--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

"charia" <cha...@discussions.microsoft.com> wrote in message
news:8305BE3F-3531-4F08...@microsoft.com...

On 10 November 2009 02:24
Andrew Walker wrote:

Text Wrapping within Outlook 2007
Hey everyone,

I am trying to create an email signature that pulls all it's information from Active Directory. This is working fine but I also have an image in the signature and I need to change the wrapping to 'Square'.

Basically I want all of the signature text to appear to the right of the image (which it does when set to Square).

I am currently using the below but it is not changing the wrapping..

Set objShape = objSelection.InlineShapes.AddPicture("C:\image002.jpg, LinkToFile:=False, SaveWithDocument:=True")
Set objShape = objSelection.InlineShapes(1).ConvertToShape
objShape.WrapFormat.Type = wdWrapSquare

I did manage to get this to work within Word 2007 but not with Outlook.

Any help would be greatly appreciated.

Thanks in advance

EggHeadCafe - Software Developer Portal of Choice
Insert Records - XML/ADO Marshalling Over The Net
http://www.eggheadcafe.com/tutorials/aspnet/51fcbff2-781f-4312-bb29-621bdddd8638/insert-records--xmlado.aspx

daniel...@gmail.com

unread,
Mar 28, 2017, 3:47:07 PM3/28/17
to
I know this is very old post but I believe this is the answer.
Word has predefined constants loaded, VBScript/Outlook do not.
There may be a library of constants you can load but here is how I accomplished it. See https://msdn.microsoft.com/en-us/library/bb214041(v=office.12).aspx and also https://msdn.microsoft.com/en-us/library/office/aa220934(v=office.11).aspx

Add this constant to your script:
const wdWrapSquare = 0

or change objShape.WrapFormat.Type = wdWrapSquare
to objShape.WrapFormat.Type = 0

My VBScript code for image in Outlook signature:

objSelection.InlineShapes.AddPicture("\\dc2\wfc\WFC - Business Cards & Signatures\Images\WFC_Logo.PNG")
With objDoc
.Hyperlinks.Add .InlineShapes.Item(1), "http://www.my_company.org"
Set objLogo = .InlineShapes.Item(1).ConvertToShape
End With
With objLogo
.WrapFormat.Type = wdWrapSquare
.WrapFormat.DistanceLeft = 0
.WrapFormat.DistanceRight = 0
.Wrap.Side = wdWrapRight
End With

Here are all WrapFormat values:
' Places shapes in line with text.
const wdWrapInline = 7
' Places shape in front of text.
const wdWrapNone = 3
' Wraps text around the shape.
' Line continuation is on the opposite side of the shape.
const wdWrapSquare = 0
' Wraps text around the shape.
const wdWrapThrough = 2
' Wraps text close to the shape.
const wdWrapTight = 1
' Places text above and below the shape.
const wdWrapTopBottom = 4
' Places shape behind text.
const wdWrapBehind = 5
' Places shape in front of text.
const wdWrapFront = 6

Not WrapFormat but here are others I've needed:
const wdCharacter = 1
const wdWord = 2
const wdSentence = 3
const wdParagraph = 4
const wdLine = 5
const wdStory = 6
const wdScreen = 7
const wdSection = 8
const wdColumn = 9
const wdRow = 10
const wdWindow = 11
const wdCell = 12
const wdCharacterFormatting = 13
const wdParagraphFormatting = 14
const wdTable = 15

const wdUnderlineSingle = 1
const wdExtend = 1
const wdCollapseEnd = 0

tpra...@gmail.com

unread,
Jun 23, 2017, 3:14:08 PM6/23/17
to
This helped me with my outlook signature policy in 2017..

Added the constant and this to just below the image line:
With objDoc
.Hyperlinks.Add .InlineShapes.Item(1), "http://www.my_company.org"
Set objLogo = .InlineShapes.Item(1).ConvertToShape
End With
With objLogo
.WrapFormat.Type = wdWrapSquare
.WrapFormat.DistanceLeft = 0
.WrapFormat.DistanceRight = 0
.Wrap.Side = wdWrapRight
End With

Worked like a champ
0 new messages