我试图用VBA将一些数据放入剪贴板
代码如下:
$('#container').highcharts({
chart: {
type: 'lineargauge',
events: {
load: function() {
this.counterBox = $("#counter-box");
// Because chart is inverted, use plotWidth & plotY:
this.counterBox.css({
left: this.plotWidth - this.series[0].points[0].plotY + 'px'
});
},
redraw: function() {
this.counterBox.animate({
left: this.plotWidth - this.series[0].points[0].plotY + 'px'
});
}
},
margin: [100, 20, 40, 20],
inverted: true
},
...
});
这段代码要做的是获取一个Range中的任何给定信息,接受它并将其放入一个格式为'data'的单个字符串中。 'data2',& ...
但是我遇到的问题是将我的信息放入剪贴板的最后一部分。我得到了
你能救我吗?我认为错误可能在ArrayString上,实际上是一个Array,应该是一个String,但我只是在猜测。错误424,需要一个对象。
提前感谢您的帮助!
最好的问候
答案 0 :(得分:0)
@vicentG给出的解决方案是在同一行添加第一个Dim和new!
Sub PasaraformatoSQLDATA()
Dim clipboard As new MSForms.DataObject
Dim ArraySelc As Variant
Dim SourceRange As Range
Dim Lenr As Long
Dim ArrayString As Variant
Set SourceRange = Selection.CurrentRegion
ArraySelct = SourceRange.Value
Lenr = UBound(ArraySelct)
For i = 1 To Lenr
ArraySelct(i, 1) = "'" & ArraySelct(i, 1) & "'"
Next i
'Condicion zero
ArrayString = ArraySelct(1, 1)
'Rellenar el resto
For p = 2 To Lenr
ArrayString = ArrayString & "," & ArraySelct(p, 1)
Next p
clipboard.SetText ArrayString
clipboard.PutInClipboard
End Sub