Modify MSword VBA code to Excel VBA code

aayaanmayank

Board Regular
Joined
Jul 20, 2018
Messages
157
Hi

can someone suggest what are the changes need to make so below code can work in excel/outlook via html or so. i have found two codes from Microsoft docs.

VBA Code:
Sub PictureFormat()

Set myDocument = ActiveDocument
With WrapFormat
Selection.ShapeRange.WrapFormat.Type = wdWrapTopandbottom
End With

End Sub
VBA Code:
Sub PictureFormat()
If Selection.ShapeRange.Count = 0 Then
If Selection.InlineShapes.Count = 1 Then
Selection.InlineShapes(1).ConvertToShape
Else
MsgBox "Select a picture first.", , "Oops!"
Exit Sub
End If
End If

With Selection.ShapeRange(1)
.Top = CentimetersToPoints(0.5)
.RelativeVerticalPosition = _
wdRelativeVerticalPositionParagraph
.Left = CentimetersToPoints(3)
.RelativeHorizontalPosition = _
wdRelativeHorizontalPositionColumn
With .WrapFormat
.Type = wdWrapTopBottom
.DistanceTop = CentimetersToPoints(0.2)
.DistanceBottom = CentimetersToPoints(0.2)
End With
End With
End Sub
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Your question doesn't really make any sense, in my opinion. Excel and Outlook are very different, and what you have is code for Word, so what is it you actually want to achieve?
 
Upvote 0
Your question doesn't really make any sense, in my opinion. Excel and Outlook are very different, and what you have is code for Word, so what is it you actually want to achieve?
The way WRAP TOPANDBOTTAM is working in word. i am looking same for excel which embeds image is outlook via HTML. I hope now it make sense.
 
Upvote 0
Your question doesn't really make any sense, in my opinion. Excel and Outlook are very different, and what you have is code for Word, so what is it you actually want to achieve?
It has been more then 2 years and this Forum never disappointed me but it feels like this time i am gonna fail.
 
Upvote 0
That code has nothing at all to do with embedding and formatting an image in Outlook from Excel, so it's not really of any use. I suggest you start again with a clear description of exactly what it is you need.

Also, please do not bump your thread more than once a day. It actually reduces your chances of getting help.
 
Upvote 0

Forum statistics

Threads
1,223,637
Messages
6,173,488
Members
452,515
Latest member
archcalx

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top