darijokesar
New Member
- Joined
- Dec 23, 2016
- Messages
- 5
Hope somebody would be able to resolve this puzzle. Please take a look at the code I have created. It works just fine but with one repeated action I cannot seems to get rid of. Idea behind Macro is to open Insert Object dialog box so I can choose a pdf file and insert it in the sheet. Also, to size and move it to my particular needs. If user cancels it would exit the sub. Now, everything works fine but for some reason when pdf file is selected dialog box closes and opens for second time and then when file again selected it gets placed in the sheet. Any help to get rid of this would be greatly appreciated
</code>
Code:
<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">Sub InsertObject()
Dim fullFileName As String
fullFileName = Application.GetOpenFilename("*.*, All Files", , , , False)
If fullFileName = "False" Then
Exit Sub
End If
ActiveSheet.OLEObjects.Add(ClassType:="AcroExch.Document.DC", Link:=False, DisplayAsIcon:=False).Activate
ActiveSheet.Shapes.SelectAll
With Selection.ShapeRange
.LockAspectRatio = msoFalse
.Height = Application.InchesToPoints(14.22)
.Width = Application.InchesToPoints(9.29)
.Top = Application.InchesToPoints(26.91)
.Left = Application.InchesToPoints(91.8750393701)
End With
End Sub