Copy text file from web server to local drive

C

Cliff72

Is there a way in VBA to copy a file from a web server to a local
drive? Example:
Every morning at 3AM a huge mainframe report is run and a copy of
this report is saved as a text file on a web server:
http://GLJobs.CliffKing.com/Reports_txt/MyReport101007.txt
The name of my report is:
MyReport101007.txt

I manually download this report to the C:\ drive and then manually
import it into access.
Is there a way i can programmatically do this?

Thanks

Cliff
 
E

Evertjan.

Randy Webb wrote on 11 okt 2007 in comp.lang.javascript:
(e-mail address removed) said the following on 10/10/2007 8:15 PM:

I will have to remember the next time I have a VBA question that I
should ask it in a Javascript newsgroup rather than in a VBA group.

We will help you remember, Randy.
 
D

drink.the.koolaid

Is there a way in VBA to copy a file from a web server to a local
drive?

Your post was fine if you just asked "Is there a way in javascript
to..."
On windows you can do this:

Create a text file called c:\GetWebPage.js:

var fso = new ActiveXObject('Scripting.FileSystemObject');
var args = WScript.Arguments;
var url = args(0);
var fileName = args(1);
var xmlhttp=new ActiveXObject("microsoft.xmlhttp");
xmlhttp.open("GET", url, false);
xmlhttp.send();
var data=xmlhttp.responsetext;
var file = fso.CreateTextFile(fileName, 2);
file.writeLine(data);
file.close();
From a command line type:
cscript /nologo c:\GetWebPage.js http://www.YOUR_URL_HERE.com c:
\YOUR_OUTPUT_FILE_HERE.txt
 
C

Cliff72

Your post was fine if you just asked "Is there a way in javascript
to..."
On windows you can do this:

Create a text file called c:\GetWebPage.js:

var fso = new ActiveXObject('Scripting.FileSystemObject');
var args = WScript.Arguments;
var url = args(0);
var fileName = args(1);
var xmlhttp=new ActiveXObject("microsoft.xmlhttp");
xmlhttp.open("GET", url, false);
xmlhttp.send();
var data=xmlhttp.responsetext;
var file = fso.CreateTextFile(fileName, 2);
file.writeLine(data);
file.close();


cscript /nologo c:\GetWebPage.jshttp://www.YOUR_URL_HERE.comc:
\YOUR_OUTPUT_FILE_HERE.txt

Thanks for your help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top