View Single Post
 
Old 04-14-2022, 07:17 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

This code works as a starting point. There are subtle points that you may need to use to refine the location of the graphic. PinX and PinY is dependent on the LocPinX and LocPinY which may not be the middle of both the shp or the shpNew. Then you a question about sizing/relative sizing of the graphic.
Code:
Sub ProcessPage()
  Dim shp As Shape, pg As Page, sPath As String, sFile As String
  Dim dSpcX As Double, dSpcY As Double, shpNew As Shape
    
  sPath = ActiveDocument.Path
  For Each pg In ActiveDocument.Pages
    For Each shp In pg.Shapes
      If shp.CellExists("Prop.Number", 0) Then
        dSpcX = shp.Cells("PinX")
        dSpcY = shp.Cells("PinY")
        sFile = Replace(shp.Cells("Prop.Number").Formula, """", "")
        Debug.Print sPath, sFile
        Set shpNew = pg.Import(sPath & sFile & ".png")
        With shpNew
          .Cells("PinX") = dSpcX
          .Cells("PinY") = dSpcY
        End With
      End If
    Next shp
  Next pg
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote