I have this code which works great. I can insert images and define the area that I want it to reside in. The issue is I would like it to work for PDF and DWF images as well. I've added the extensions into the code. When I run the code it will show me pdf and dwf files but when I select them I receive an error "An error occured while importing this file". When I debug this code line is highlighted
. The jpg, gif, bmp & tif files all import properly it's only the pdf and dwf files that fail.
Can anybody please assist me in correcting this or advise me if this is possible or not?
Here's the code I'm currently using.
Code
Sub InsertFloorPlan()
Dim sPicture As String, pic As Picture
sPicture = Application.GetOpenFilename _
("Pictures (*.gif; *.jpg; *.bmp; *.tif; *.pdf; *.dwf), *.gif; *.jpg; *.bmp;
*.tif; *.pdf; *.dwf", _
, "Select Picture to Import")
If sPicture = "False" Then Exit Sub
Set pic = ActiveSheet.Pictures.Insert(sPicture)
With pic
.ShapeRange.LockAspectRatio = msoFalse
.Height = Range("a7:a45").Height
.Width = Range("a7:i7").Width
.Top = Range("a7").Top
.Left = Range("a7").Left
.Placement = xlMoveAndSize
End With
Set pic = Nothing
End Sub
Display More