使用VBA我想将当前word文档的副本发送到Web服务?如何将当前文档作为字节数组?
我知道如何使用Web服务只是不知道如何将当前文件作为二进制对象发送?
ps我今天早上才使用VBA =)所以简单的答案是值得赞赏的
Oor*_*ang 10
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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6266 次 |
| 最近记录: |