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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With