Excel 的 Application
对象有一个 ClipboardFormats
属性。从文档:
但是,当我运行以下代码时:
var app = new ActiveXObject('Excel.Application');
app.Visible = true;
var results = new VBArray(app.ClipboardFormats).toArray();
app.Quit();
window.alert(results.join(','));
我回来了:
0
对应于 XlClipboardFormat.xlClipboardFormatText ,但其他值在 XlClipboardFormat 枚举中没有匹配的枚举成员。44
和 50
作为剪贴板格式值是什么意思? 最佳答案
不知道这对走得更远有多大帮助,但以 this source 为例,我想出了以下测试代码:
Option Explicit
Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function CloseClipboard Lib "user32" () As Long
Private Declare Function GetClipboardData Lib "user32" (ByVal wFormat As Long) As Long
Private Declare Function EmptyClipboard Lib "user32" () As Long
Private Declare Function EnumClipboardFormats Lib "user32" _
(ByVal wFormat As Long) As Long
Private Declare Function GetClipboardFormatName Lib "user32" _
Alias "GetClipboardFormatNameA" (ByVal wFormat As Long, _
ByVal lpString As String, _
ByVal nMaxCount As Long) As Long
Private Sub test()
Dim results As Variant
Dim fmtName As String
Dim fmt As Long
Range("A1").Copy
results = Application.ClipboardFormats
Debug.Print "For cell A1 (plain) = " & Join(results, ",")
ClipboardFormats
Range("A2").Copy
results = Application.ClipboardFormats
Debug.Print "For cell A2 (bold ) = " & Join(results, ",")
ClipboardFormats
End Sub
Private Sub ClipboardFormats()
Dim fmt As Long
Dim fmtName As String
Dim iClipBoardFormatNumber As Long
OpenClipboard 0&
If iClipBoardFormatNumber = 0 Then
fmt = EnumClipboardFormats(0)
Do While fmt <> 0
fmtName = Space(255)
GetClipboardFormatName fmt, fmtName, 255
fmtName = Trim(fmtName)
If fmtName <> vbNullString Then
fmtName = Left(fmtName, Len(fmtName) - 1)
Debug.Print "fmtName (" & fmt & ") = " & fmtName
End If
fmt = EnumClipboardFormats(fmt)
Loop
End If
EmptyClipboard
CloseClipboard
End Sub
输出很有趣,但不一定有启发性:
关于vba - ClipboardFormat 值 44 和 50 的含义,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/50588906/