从FSO粘贴选定的图片

时间:2015-10-22 12:32:17

标签: excel vba

Dim p As Picture
Dim sPath As String, sFileName As String, s As String

sPath = "C:\Users\Vivek\Downloads\SMCS\"

'Open browser to select a picture
Thisfile = Application.GetOpenFilename

sFileName = Thisfile
s = sPath & sFileName
ActiveSheet.Pictures.insert (s)

此代码为我提供了错误1004:图片类的插入方法失败

我想在单元格C6中粘贴复制到图纸中的图片(" CONSOLE")。

1 个答案:

答案 0 :(得分:0)

检查您的保护和权限。这似乎有效:

Sub GetAPicture()
   Dim s As String, sh As Worksheet
   s = "C:\TestFolder\tempxx.jpg"
   Set sh = ActiveSheet
   sh.Pictures.Insert (s)
End Sub