views:

28

answers:

0

This question has been asked many times by others in some form or another but most remained unanswered or the given answer is "Use C#, duh!", which incidentally, is a non-answer. ;-)

I want to upload a zip file to a web server via VBA. The server side code already exists and works well; it accepts zip files via manual form upload and does something with the contents of the zip file.

The theory is, I plan to transform the binary contents of the zip file into a HTTP request string and send it to the server using some methods from the WinHTTP library. If everything goes well the server side script (in Perl) shouldn't be able to tell whether the file came from VBA or a browser and continue working normally.

However, transmogrifying the zip file to a HTTP request string doesn't seem to be very straight forward.

Searching online seems to indicate there exists 3 common strategies:

Method 1: WinHTTP and manual encoding of binary to HTTP request string

  • Involves opening the file in binary mode and manually applying some encoding voodoo to change the binary stream into a HTTP request string and send it on its way using WinHTTP. Scary amount of code.

Method 2: WinHTTP

  • Involves using the ADODB.Stream. Less than ten lines of code.

Method 3: Automate IE via SendKeys

  • There's only one word to describe this hack : Yuck! And probably will break in future version of IE, if not already. Less than ten lines of code. Security risk.

I leaning towards Method 2, however, documentation is thin, code examples rare, and there's no certainty that it works. Most code examples are incomplete and often have comments that say they don't work. Does this method actually work?

Method 1 is next in line.

Method 3 Please, no! (Rather use C# if it comes to that. Love C#, just the requirements only permit VBA)

Anyone has any good examples on how to accomplish this task?