2

I am trying to download files from the server.I have VBA code which makes a call to a C# web service and gets an array of bytes..I am now trying to figure out,how can I write the byte array to a file on my local machine through VBA code

2
  • You are using C# and why do you want to use VBA to the latter part? Why not do all in C#? Can you describe a bit more what you are really trying to do here? :) Commented Jan 16, 2013 at 21:09
  • @bonCodigo - I suspect the user1984867 does not have a choice: most likely the client app is an Excel spreadsheet that pulls down data and displays it. Often developers don't have a choice over the technologies they use - that choice is made by the business or is made for them by other constraints. Commented May 16, 2016 at 9:12

2 Answers 2

9
open "output.bin" for binary access write as #1
lWritePos=1
put #1, lWritePos, vData
close #1

http://www.visualbasic.happycodings.com/Files_Directories_Drives/code52.html

Sign up to request clarification or add additional context in comments.

1 Comment

See my answer (which should have been a comment to this post) below
3

vData needs to be defined as Dim vData() as byte. The decodeBase64 function which converts the (image) encoded string (link to it in this answer) returns a byte array and if it is passed back to a variant, the resulting data file will not open.

1 Comment

It would have helped to explain why there is such a need. Right now, we can only guess, or perhaps have educated guesses.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.