Can anyone tell me what is wrong with this code?
It loads a specific picture file, resizes it and sets it 'behind' text at the cursor point, just as it is meant to do but only if run under DEBUG, stepping through each line. If you just RUN it, it does nothing, but does not give an error.
I guess it has something to do with initialization or completion, but can't figure out what.
Sub pcn()
'
' pcn Macro
' Macro to insert signature 2016/11/20
'
Dim oDialog As Dialog
Dim oImage As Object
Dim oRng As Range
Set oImage = Selection.InlineShapes.AddPicture("D:\DOCUMENTS\PCN\pcnsig.png")
With oImage
.LockAspectRatio = msoTrue
.Height = 0.2 * .Height
.Width = 0.2 * .Width
Set oRng = oImage.Range
.ConvertToShape
End With
With oRng.ShapeRange(1)
.ZOrder msoSendBehindText
.WrapFormat.Type = wdWrapNone
End With
Set oDialog = Nothing
Set oImage = Nothing
Set oRng = Nothing
End Sub
The code from derived from examples culled from contributions elsewhere on this site. Thanks!
I am trying to run it on an ancient version of Word - 2000 under windows 10. It still works ok and I don't have problems with other versions of this macro.
PhillipN
It loads a specific picture file, resizes it and sets it 'behind' text at the cursor point, just as it is meant to do but only if run under DEBUG, stepping through each line. If you just RUN it, it does nothing, but does not give an error.
I guess it has something to do with initialization or completion, but can't figure out what.
Sub pcn()
'
' pcn Macro
' Macro to insert signature 2016/11/20
'
Dim oDialog As Dialog
Dim oImage As Object
Dim oRng As Range
Set oImage = Selection.InlineShapes.AddPicture("D:\DOCUMENTS\PCN\pcnsig.png")
With oImage
.LockAspectRatio = msoTrue
.Height = 0.2 * .Height
.Width = 0.2 * .Width
Set oRng = oImage.Range
.ConvertToShape
End With
With oRng.ShapeRange(1)
.ZOrder msoSendBehindText
.WrapFormat.Type = wdWrapNone
End With
Set oDialog = Nothing
Set oImage = Nothing
Set oRng = Nothing
End Sub
The code from derived from examples culled from contributions elsewhere on this site. Thanks!
I am trying to run it on an ancient version of Word - 2000 under windows 10. It still works ok and I don't have problems with other versions of this macro.
PhillipN