Open Filename + SendKeys

M

Matthew

I am writing a macro for Excel 2002 in VB. I am opening a .csv file from a
protected part of my web site. I have a dialog box requesting my user name
and password. Excel remembered the values from last time, so all I have to
do is click "OK" or hit enter on the keyboard.

I tried the following script, but it seems to want to finish Open Filename
before going on to SendKeys.

Workbooks.Open Filename:= _
"http://www.osbornewood.com/_private/test.csv"
SendKeys "{ENTER}"

How can I make it go on to the next step without waiting for the document to
actually open? (The SendKeys "{ENTER}" is to get past the dialog box.)

Is this the right general idea, or am I totally on the wrong track?

Matthew
 
M

Matthew

John,

That looks good. However, when I tried it I got the error message:

Compile error:
Syntax error

I looked at it in the debugger, and tried again. The next time it said:

Compile error:
Expected: named parameter

It highlighted the first line. I put the second line (password) on the
first line; it liked that (no error messages) but it still displayed the
dialog box, waiting for me to hit OK.

Matthew
 
J

jaf

Hi Matthew,
It was one line, it wrapped in the newsreader. There should be a comma
before password.
 
M

Matthew

If anybody is interested, the answer was to put "SendKeys" before
"Workbooks.Open Filename".

Matthew
 

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

Top