VBA WS Toolkit,如何将当前文件作为字节数组获取 [英] VBA WS Toolkit, how to get current File as Byte Array
本文介绍了VBA WS Toolkit,如何将当前文件作为字节数组获取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 VBA 我想将当前 Word 文档的副本发送到网络服务?如何将当前文档作为字节数组获取?
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?
附言从今天早上开始我一直在使用 VBA =) 非常感谢简单的答案
p.s. I have only been using VBA since this morning =) So simple answers are appreciated
推荐答案
Public Sub Example()
Dim bytFile() As Byte
bytFile = GetFileBytes("c: estdirdump.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
这篇关于VBA WS Toolkit,如何将当前文件作为字节数组获取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文