VBA WS Toolkit,如何获取当前文件作为字节数组

发布于 2024-08-03 07:52:08 字数 146 浏览 0 评论 0原文

使用 VBA 我想将当前 Word 文档的副本发送到 Web 服务?如何以字节数组形式获取当前文档?

我知道如何使用 Web 服务,只是不确定如何将当前文件作为二进制对象发送?

ps 我从今天早上开始只使用 VBA =) 所以简单的答案值得赞赏

Using VBA I want to send a copy of the current word document to a web service? How can is get the current document as a Byte Array?

I know how to use the web service just not sure how to get the current file as a binary object to send?

p.s. I have only been using VBA since this morning =) So simple answers are appreciated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ゞ花落谁相伴 2024-08-10 07:52:08
Public Sub Example()
    Dim bytFile() As Byte
    bytFile = GetFileBytes("c:\test\dirdump.doc")
    ''// Do something with bytFile here.
End Sub

Public Function GetFileBytes(ByVal path As String) As Byte()
    Dim lngFileNum As Long
    Dim bytRtnVal() As Byte
    lngFileNum = FreeFile
    If LenB(Dir(path)) Then ''// Does file exist?
        Open path For Binary Access Read As lngFileNum
        ReDim bytRtnVal(LOF(lngFileNum) - 1&) As Byte
        Get lngFileNum, , bytRtnVal
        Close lngFileNum
    Else
        Err.Raise 53
    End If
    GetFileBytes = bytRtnVal
    Erase bytRtnVal
End Function
Public Sub Example()
    Dim bytFile() As Byte
    bytFile = GetFileBytes("c:\test\dirdump.doc")
    ''// Do something with bytFile here.
End Sub

Public Function GetFileBytes(ByVal path As String) As Byte()
    Dim lngFileNum As Long
    Dim bytRtnVal() As Byte
    lngFileNum = FreeFile
    If LenB(Dir(path)) Then ''// Does file exist?
        Open path For Binary Access Read As lngFileNum
        ReDim bytRtnVal(LOF(lngFileNum) - 1&) As Byte
        Get lngFileNum, , bytRtnVal
        Close lngFileNum
    Else
        Err.Raise 53
    End If
    GetFileBytes = bytRtnVal
    Erase bytRtnVal
End Function
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文