Excel macro -> browse file -> select file

Closed
Tobie OVerdijk - Apr 18, 2010 at 06:38 AM
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 - Apr 21, 2010 at 06:13 AM
Hey there,

I got a old excel project with a macro in it.

To explain what it does is:

1. It opens a webpage -WORKS-
2. Saves an image from the webpage -WORKS-
3. Opens another page -WORKS-
4. Prints the code in the first textbox -WORKS-
5. Open a browse window -WORKS-
6. Selects a file location and submits -NOT WORKING-


Now what i need to get working is a browse box wich will automaticly select me a file and opens it, so it can be uploaded by the browser

Preview:
http://tinypic.com/images/goodbye.jpg


Code:
Call NPDelete_File(ActiveWorkbook.Path & ".\Captcha.jpg")
    Call SaveWebFile(Mid(IE.document.body.innerhtml, iStart, iPlace - iStart), ActiveWorkbook.Path & ".\Captcha.jpg")
    Call SolveCaptcha("sa8d4a8d4as7d4w74da78s4da78s4d78ad", Application.Path & "\Captcha.jpg")
Related:

8 responses

rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Apr 18, 2010 at 09:25 AM
could you put a sample file with code. This is partial code, and is not enough to see what can be issue. Also what version of excel you have. You can put the file at some share site like https://authentification.site and post back the link here
0
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Apr 19, 2010 at 02:58 AM
Your issue is here

If UCase(objInputElement.Type) = "FILE" Then

Application.Wait (Now() + TimeValue("00:00:01"))

objInputElement.Focus

Application.Wait (Now() + TimeValue("00:00:01"))

'objInputElement.Click

' Application.Wait (Now() + TimeValue("00:00:03"))

SendKeys sFile



The send keys does not work. HTML form element "FILE" does not allow a value to be set. I have never used IMACRO but they say that it is good for type of things that you are seeking to do, In fact the web site where you are uploading the image is also gives a sample code for that. Here is the website for it
http://www.iopus.com/imacros/


By the way semi automate way would be if you make this change. In this case you have to select the file yourself, but the file selection dialogbox would open up


If UCase(objInputElement.Type) = "FILE" Then

Application.Wait (Now() + TimeValue("00:00:01"))

objInputElement.Focus

Application.Wait (Now() + TimeValue("00:00:01"))

objInputElement.Click

Application.Wait (Now() + TimeValue("00:00:03"))

'SendKeys sFile
0
Tobie OVerdijk
Apr 19, 2010 at 04:12 PM
Hey, thanks for the help! i got further.
now the browse window pops up but it does not select/open captcha.jpg
0

Didn't find the answer you are looking for?

Ask a question
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Apr 19, 2010 at 04:45 PM
I would be very interested in knowing how you were able to get past this point? You said that you were able to get past this point right ? So you were able to use the sendkeys or you opted for some alternative form?
0
Tobie OVerdijk
Apr 19, 2010 at 04:47 PM
I worked it out by replacing the code part you told me to,
Yet i still have the issue that it does not select captcha.jpg and opens it
0
Tobie OVerdijk
Apr 21, 2010 at 02:19 AM
Problem solved, thanks.
0
rizvisa1 Posts 4478 Registration date Thursday January 28, 2010 Status Contributor Last seen May 5, 2022 766
Apr 21, 2010 at 06:13 AM
how? what u changed
0