How to inject VBA code in web application

dprasad used Ask the Experts™
how to use VBA code,i wants to inject vba code while file uploading in  please let me know how...
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Could you please explain a little further what it is you're trying to do? Do you mean the file being uploaded is for example an Excel sheet and you want to add VBA code to the file?


yes,exactly i wants to add vba code to file at the time of uploading the file into server..

You will need to upload the file first, then open the file using office interop (adding the relevant references first).

There's isn't much you can't do with the document once you have got this far. Check out the following webpage on adding VBA code:

Hope that helps


Thanks gavsmith for your time and answer. This is my complete requirement please provide some solution for it.

1) User A will upload file to server.
2) user B will download the file and places it in his local machine
3) Now every time user B opens this downloaded file- it should contact the server and file should be again downloaded from server.
4) In case the file moved out of server/ server refused for download, then file should not be open.
5) In one word every time we open the file, it should be downloaded from server only.

Note : user can upload any kind of file; for time being we are considering Word,Excel and PDF files.

I hope I am more clear about my requirements.

That appears to be a different question to the original.

However it would appear to me that you do not want to allow 2 (user B will download the file and place on local machine). If you don't allow them to do that then all the rest is solved!

Just make sure in the VBA code that the document path of the opened file is a unc path containing your server name if not close the file. You can't do that on a PDF but I believe there is a security option which stops a user from saving a copy.

If this is not enough information I would suggest that you start a new question.


Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial