gpt4 book ai didi

vba - ClipboardFormat 值 44 和 50 的含义

转载 作者:行者123 更新时间:2023-12-02 10:40:23 25 4
gpt4 key购买 nike

Excel 的 Application 对象具有 ClipboardFormats 属性。来自文档:

Returns the formats that are currently on the Clipboard, as an array of numeric values.

但是,当我运行以下代码时:

var app = new ActiveXObject('Excel.Application');
app.Visible = true;
var results = new VBArray(app.ClipboardFormats).toArray();
app.Quit();
window.alert(results.join(','));

我回来了:

0, 44, 50

0 对应于 XlClipboardFormat.xlClipboardFormatText,但其他值在 XlClipboardFormat 中没有匹配的枚举成员。枚举。

作为剪贴板格式值,4450 意味着什么?

最佳答案

不知道这对走得更远有多大帮助,但以 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

输出很有趣,但不一定具有启发性:

For cell A1 (plain) = 0,2,4,5,6,7,8,9,11,12,14,17,19,22,23,31,32,33,44,45,50,58,63
fmtName (49161) = DataObject
fmtName (50023) = Biff12
fmtName (50004) = Biff8
fmtName (50006) = Biff5
fmtName (49910) = XML Spreadsheet
fmtName (49349) = HTML Format
fmtName (49566) = CSV
fmtName (49273) = Rich Text Format
fmtName (49163) = Embed Source
fmtName (49156) = Native
fmtName (49155) = OwnerLink
fmtName (49166) = Object Descriptor
fmtName (49165) = Link Source
fmtName (49167) = Link Source Descriptor
fmtName (50003) = Link
fmtName (49154) = ObjectLink
fmtName (49171) = Ole Private Data
For cell A2 (bold ) = 0,2,4,5,6,7,8,9,11,12,14,17,19,22,23,31,32,33,44,45,50,58,63
fmtName (49161) = DataObject
fmtName (50023) = Biff12
fmtName (50004) = Biff8
fmtName (50006) = Biff5
fmtName (49910) = XML Spreadsheet
fmtName (49349) = HTML Format
fmtName (49566) = CSV
fmtName (49273) = Rich Text Format
fmtName (49163) = Embed Source
fmtName (49156) = Native
fmtName (49155) = OwnerLink
fmtName (49166) = Object Descriptor
fmtName (49165) = Link Source
fmtName (49167) = Link Source Descriptor
fmtName (50003) = Link
fmtName (49154) = ObjectLink
fmtName (49171) = Ole Private Data

关于vba - ClipboardFormat 值 44 和 50 的含义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50588906/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com