Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Web Service returning a File

Status
Not open for further replies.

trScott

Technical User
Dec 13, 2004
31
0
0
US
My Access 2003 app is calling a Web Service that returns a byte array. The byte array is actually a PDF file (believe Access wants to store it as a variant).

Does anyone have an idea how I can retrieve the document and display it for my end user?

Thanks!
 
trScott,
Assuming the byte array is the complete PDF document you could cache the array to a temp file and then open the newly created temp file.

You might try something like this:
Code:
Sub CreateFileFromByte(OutputFile As String, WebServiceData As Variant)
Dim intFileNumber As Integer
intFileNumber = FreeFile
Open OutputFile For Binary As #intFileNumber
Put intFileNumber, , WebServiceData
Close #intFileNumber
End Sub

Code:
Sub Test_CreateFileFromByte()
Dim b() As Byte
Dim strPath As String, strFileName As String

'This would be your byte array from the web service
b = "The quick brown fox"

'This creates Output.pdf in the user's TEMP folder
strPath = Environ$("TEMP") & "\"
strFileName = "Output.pdf"

'Create the file
CreateFileFromByte strPath & strFileName, b
End Sub

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top