A family of Microsoft word processing software products for creating web, email, and print documents.
Floating graphics are not in the text area of the document and cannot be handled in the same way. I'll have to think about that one.
I had a play. This is the best I can come up with:
Sub ConvertFloatingShapesToJpg()
' Add a reference to Microsoft PowerPoint xx.0 Object Library' via VBE > Tools > References...'
Dim pptAp As PowerPoint.Application
Dim pptPres As PowerPoint.Presentation
Dim pptSld As PowerPoint.Slide
Dim pptShp As PowerPoint.Shape
Dim bWeStartedPpt As Boolean
Dim shp As Shape
Dim anc As Range
Dim dbL As Double, dbT As Double
Dim i As Long
Dim strPath As String
strPath = Environ("TEMP") & "\temp.jpg"
'Get PowerPoint object:
On Error Resume Next
Set pptAp = GetObject(, "PowerPoint.Application")
On Error GoTo 0
If pptAp Is Nothing Then
Set pptAp = CreateObject("PowerPoint.Application")
If pptAp Is Nothing Then
MsgBox "Unable to start PowerPoint"
Exit Sub
Else
bWeStartedPpt = True
End If
End If
'Create a blank presentation, add a blank slide:
Set pptPres = pptAp.Presentations.Add
Application.Activate 'switch back to Word, just so we can see what's going on...
Set pptSld = pptPres.Slides.Add(1, 12) '12=ppLayoutBlank
pptPres.Windows(1).View.Zoom = 100
'Loop backwards through each shape: For i = ActiveDocument.Shapes.Count To 1 Step -1
Set shp = ActiveDocument.Shapes(i)
'Record anchor-range and position of shape: Set anc = shp.Anchor
dbL = shp.Left
dbT = shp.Top
'Cut the shape: shp.Select
Selection.Cut
'Paste shp into Ppt then export to file: pptAp.ActiveWindow.View.PasteSpecial 5 '5=ppPasteJPG
Set pptShp = pptSld.Shapes(1)
pptShp.Export PathName:=strPath, Filter:=1 '1=ppShapeFormatJPG
pptSld.Shapes.Range.Delete
'Insert the file into Word at the original anchor point: anc.InlineShapes.AddPicture FileName:=strPath, _
LinkToFile:=False, _
SaveWithDocument:=True
'Convert the inline shape to floating: ActiveDocument.InlineShapes(ActiveDocument.InlineShapes.Count).ConvertToShape
'Set size and position to originals: With ActiveDocument.Shapes(ActiveDocument.Shapes.Count)
.Left = dbL
.Top = dbT
End With
Next i
'Tidy up: Set pptShp = Nothing
Set pptSld = Nothing
pptPres.Close
Set pptPres = Nothing
If bWeStartedPpt Then pptAp.Quit
Set pptAp = Nothing
End Sub
Hope that helps.
Cheers
Rich