【问题标题】:VBA WS Toolkit, how to get current File as Byte ArrayVBA WS Toolkit,如何将当前文件作为字节数组获取
【发布时间】:2009-12-16 12:42:34
【问题描述】:

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

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

附言我从今天早上开始就一直在使用 VBA =) 非常感谢您提供简单的答案

【问题讨论】:

    标签: vba ms-word


    【解决方案1】:
    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多