Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #3  
Old 01-13-2018, 11:58 PM
macropod's Avatar
macropod macropod is offline VBA to insert an image and centralize it (code included) Windows 7 64bit VBA to insert an image and centralize it (code included) Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,343
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by gmayor View Post
If you want to centralise the image it needs to be an inline shape. You can convert it, if you must, after you have centred it.
That's not necessary, actually:
Code:
Sub InsertPic()
Dim strFile As String, iShp As InlineShape, Shp As Shape, Rng As Range
On Error Resume Next
With Dialogs(wdDialogInsertPicture)
  .Display
  If .Name <> "" Then
    strFile = .Name
  Else
    Exit Sub
  End If
End With
Set Rng = Selection.Range: Rng.Collapse wdCollapseEnd
Set iShp = ActiveDocument.InlineShapes.AddPicture(strFile, False, True, Rng)
Set Shp = iShp.ConvertToShape
With Shp
  .LockAnchor = True
  .LockAspectRatio = msoTrue
  .Height = .Height / 2
  .RelativeVerticalPosition = wdRelativeVerticalPositionLine
  .Top = 0
  .RelativeHorizontalPosition = wdRelativeHorizontalPositionMargin
  .Left = wdShapeCenter
End With
Set Rng = Nothing: Set iShp = Nothing: Set Shp = Nothing
End Sub
puff: Multiple shapes can also be inserted this way, but the issue that then needs to be addressed is how their relative vertical positions are to be managed. See also:
https://www.msofficeforums.com/word-...html#post47919
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA to insert an image and centralize it (code included) Issue of 2 fixed bullet points indent setting work together (code included) puff Word VBA 5 12-17-2017 05:52 PM
VBA to insert an image and centralize it (code included) image appering as code TedW Excel 1 11-17-2015 10:11 PM
VBA to insert an image and centralize it (code included) insert Image ?? Jazz Outlook 1 09-10-2015 04:34 AM
VBA to insert an image and centralize it (code included) Insert am Image phamh PowerPoint 1 02-25-2015 04:40 AM
Background image vs. insert image lilaria PowerPoint 0 04-18-2011 08:45 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:19 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft