我需要帮助使用单元格中的路径复制和粘贴图像。
在F2中我有我的图像路径C:\ Users \ gaetan.affolter \ Desktop \ test.jpg但路径一直在变化(我需要变量F2)
我收到错误“无法获得图片类的插入正确性”
Sub Copiarimg()
Dim pic As Picture
With ActiveSheet
Set pic = .Pictures.Insert(Range("f2").Value)
With .Range("e9:g22")
pic.Top = .Top
pic.Left = .Left
pic.Width = .Width
pic.Height = .Height
End With
End With
End Sub
答案 0 :(得分:1)
您的代码似乎正常。你错过了"。"在Dir
之前?
您可以使用Sub Copiarimg()
Dim pic As Picture
Dim picSource As String
With ActiveSheet
picSource = .Range("f2").Value
If Dir$(picSource) <> "" Then
Set pic = .Pictures.Insert(picSource)
With .Range("e9:g22")
pic.Top = .Top
pic.Left = .Left
pic.Width = .Width
pic.Height = .Height
End With
Else
MsgBox "Cannot find the file " & picSource
End If
End With
End Sub
功能测试pic文件是否存在。
var Q = require('q'),
editGoogleSpreadsheet = require('edit-google-spreadsheet');
loadSpecificSheet = function(_spreadsheetName, _worksheetName) {
return Q.ninvoke(editGoogleSpreadsheet, 'load', {
debug: true,
spreadsheetName: _spreadsheetName,
worksheetName: _worksheetName,
oauth: {
email: superSecretEmail,
keyFile: superSecretKeyfile
}
});
};
google.loadSpecificSheet(spreadsheetName, worksheetName).then(
function(spreadsheet) {
console.log("loaded")
},
function(err) { node.warn("sheet failed to load: " + err); }
).then(
google.loadSpecificSheet(spreadsheetName, worksheetName).then(
function(spreadsheet) {
console.log("loaded 2")
},
function(err) { node.warn("sheet failed to load 2: " + err); }
)
).catch(function(err) { node.warn("ToGoogleSheetNode Error: " + err); });
console.log("promises added to queue");
答案 1 :(得分:0)
我发现您的代码没有问题,请检查两件事: