我编写了一个代码来自动插入和调整图片大小。这在我的计算机上工作正常,但是朋友收到了几天
运行时错误448
我们都使用相同版本的Excel 2016.代码是在Excel 2007中编写的,并在按 Ctrl + P 时激活。有什么问题和解决方案?
Sub InsertAndSizePhoto()
Dim sFileName As String
Dim oShape As Shape
If TypeName(ActiveSheet) <> "Worksheet" Then Exit Sub
Dim myPath As String
Dim folderPath As String
folderPath = Application.ActiveWorkbook.Path
sFileName = Application.GetOpenFilename( _
FileFilter:="Images (*.gif;*.jpg;*.png), *.gif;*.jpg;*.png", _
FilterIndex:=1, _
Title:="Insert Picture", _
ButtonText:="Insert", _
MultiSelect:=False)
If sFileName = "False" Then Exit Sub
With ActiveCell.MergeArea
ActiveSheet.Shapes.AddPicture _
Filename:=sFileName, _
LinkToFile:=msoFalse, _
SaveWithDocument:=msoTrue, _
Left:=.Left, _
Top:=.Top, _
Width:=.Width, _
Height:=.Height
End With
End Sub