-
Mar 22nd, 2014, 08:15 PM
#1
Thread Starter
New Member
dont know how to deal with windows messages - apologies if it's obvious
I am extracting information from a website. This would be completed regularly and automatically. But I have hit a wall.
Using a webbrowser I have opened the website and logged on. Problems start when I click on a hyperlink which opens an excel file. Two windows messages appear.
1)How can I deal with the window which says "do you want to open or save this file"(I'd like to save it)
2)The file which opens is a .xls file which brings up another window ".........is in a different format than that specified by the file extension Do you want to open the file now?"
Can I deal with these messages during runtime. I realise sendkeys might be an option but wondered if there was another possibility.
-
Mar 22nd, 2014, 08:27 PM
#2
Re: dont know how to deal with windows messages - apologies if it's obvious
i'd intercept the hyperlink click + open the .xls manually with Microsoft.Office.Interop.Excel, + set DisplayAlerts = False.
here's an example:
http://social.msdn.microsoft.com/For...les-from-vbnet
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Mar 22nd, 2014, 11:12 PM
#3
Fanatic Member
Re: dont know how to deal with windows messages - apologies if it's obvious
Hi,
or if your just looking to save it use a webclient to download it
Code:
Dim urlfromlink as string
Dim wc As New System.Net.WebClient
wc.DownloadFile(urlfromlink, "C:\afile.xls")
you would get the href from the link to fill urlfromlink and just save it where you wish and named whatever you wish
My CodeBank Submissions
- Listbox with transparency and picture support - Click Here
- Check for a true internet connection - Click Here
- Open Cash drawer connected to receipt printer - Click Here
- Custom color and size border around form - Click Here
- Upload file to website without user logins, includes PHP - Click Here
- List All Removable USB Storage Devices - Click Here
- Custom On/Off Slide Control - Click Here
- Insert multiple rows of data into one database table using parameters - Click Here
- Trigger USB/Serial Cash Drawer - Click Here
-
Mar 22nd, 2014, 11:21 PM
#4
Re: dont know how to deal with windows messages - apologies if it's obvious
Originally Posted by bensonsearch
Hi,
or if your just looking to save it use a webclient to download it
Code:
Dim urlfromlink as string
Dim wc As New System.Net.WebClient
wc.DownloadFile(urlfromlink, "C:\afile.xls")
you would get the href from the link to fill urlfromlink and just save it where you wish and named whatever you wish
bensonsearch gave you the best answer there. I missed the most important (I'd like to save it) part
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Mar 22nd, 2014, 11:27 PM
#5
Re: dont know how to deal with windows messages - apologies if it's obvious
Originally Posted by .paul.
bensonsearch gave you the best answer there. I missed the most important (I'd like to save it) part
Not in any case. Paul you obviously missed the OP needs to be logged in.
-
Mar 22nd, 2014, 11:57 PM
#6
Fanatic Member
Re: dont know how to deal with windows messages - apologies if it's obvious
Thanx Paul I have been guilty of missing keywords a few times
My CodeBank Submissions
- Listbox with transparency and picture support - Click Here
- Check for a true internet connection - Click Here
- Open Cash drawer connected to receipt printer - Click Here
- Custom color and size border around form - Click Here
- Upload file to website without user logins, includes PHP - Click Here
- List All Removable USB Storage Devices - Click Here
- Custom On/Off Slide Control - Click Here
- Insert multiple rows of data into one database table using parameters - Click Here
- Trigger USB/Serial Cash Drawer - Click Here
-
Mar 23rd, 2014, 05:28 AM
#7
Thread Starter
New Member
Re: dont know how to deal with windows messages - apologies if it's obvious
hi and thanks for what could be a lifesaver. I wouldn't have even considered your approach - but guess that's experience.
anyway, when I run the program I get a message box telling me that an error has occurred. When I try and catch the error, I see this in debug.print.
"A first chance exception of type 'System.Net.WebException' occurred in System.dll
An exception of type 'System.Net.WebException' occurred in System.dll but was not handled in user code
Additional information: The remote server returned an error: (500) Internal Server Error."
the file does not save.
Any idea? This seems to cover about a million things!!
-
Mar 23rd, 2014, 05:34 AM
#8
Fanatic Member
Re: dont know how to deal with windows messages - apologies if it's obvious
From what you have there it could be anything, but I would say one of 2 things. 1 the server encountered an issue and try another time or 2 the link you have passed it a link that is invalid or tried to go somewhere that doesn't exist. do you have the code that didn't work so we can see?
My CodeBank Submissions
- Listbox with transparency and picture support - Click Here
- Check for a true internet connection - Click Here
- Open Cash drawer connected to receipt printer - Click Here
- Custom color and size border around form - Click Here
- Upload file to website without user logins, includes PHP - Click Here
- List All Removable USB Storage Devices - Click Here
- Custom On/Off Slide Control - Click Here
- Insert multiple rows of data into one database table using parameters - Click Here
- Trigger USB/Serial Cash Drawer - Click Here
-
Mar 23rd, 2014, 05:58 AM
#9
Thread Starter
New Member
Re: dont know how to deal with windows messages - apologies if it's obvious
Wow what a quick reply - thanks. This is the codewhich is throwing up the problem
Dim urlfromlink As String
urlfromlink = "http://www.mymaths.co.uk/assessmentManager/resultsOhLevelSummaryExcel.asp?"
Dim wc As New System.Net.WebClient
Debug.Print(GetDesktop().ToString & "\mymaths info1\myfile.xls")
wc.DownloadFile(urlfromlink, GetDesktop().ToString & "\mymaths info1\myfile.xls")
-
Mar 23rd, 2014, 06:13 AM
#10
Fanatic Member
Re: dont know how to deal with windows messages - apologies if it's obvious
that weblink is not complete, there should be things after the ?
My CodeBank Submissions
- Listbox with transparency and picture support - Click Here
- Check for a true internet connection - Click Here
- Open Cash drawer connected to receipt printer - Click Here
- Custom color and size border around form - Click Here
- Upload file to website without user logins, includes PHP - Click Here
- List All Removable USB Storage Devices - Click Here
- Custom On/Off Slide Control - Click Here
- Insert multiple rows of data into one database table using parameters - Click Here
- Trigger USB/Serial Cash Drawer - Click Here
-
Mar 23rd, 2014, 06:25 AM
#11
Thread Starter
New Member
Re: dont know how to deal with windows messages - apologies if it's obvious
I right clicked on the "button" which would be pressed manually and the properties showed this as the url.
-
Mar 23rd, 2014, 06:30 AM
#12
Fanatic Member
Re: dont know how to deal with windows messages - apologies if it's obvious
hmmm, have you tried looking at the source code? are you able to share the source or at least that part? if you use chrome you can choose inspect element which will also give info
My CodeBank Submissions
- Listbox with transparency and picture support - Click Here
- Check for a true internet connection - Click Here
- Open Cash drawer connected to receipt printer - Click Here
- Custom color and size border around form - Click Here
- Upload file to website without user logins, includes PHP - Click Here
- List All Removable USB Storage Devices - Click Here
- Custom On/Off Slide Control - Click Here
- Insert multiple rows of data into one database table using parameters - Click Here
- Trigger USB/Serial Cash Drawer - Click Here
-
Mar 23rd, 2014, 06:34 AM
#13
Thread Starter
New Member
Re: dont know how to deal with windows messages - apologies if it's obvious
<a class="linkBlueSize12" href="resultsOhLevelSummaryExcel.asp?"> Summary of Levels <img width="20" height="20" src="images/iconExcel.png" border="0"></a>
Is this what you mean?
-
Mar 23rd, 2014, 06:38 AM
#14
Fanatic Member
Re: dont know how to deal with windows messages - apologies if it's obvious
That is what im looking for but is not really helpful. We can tell its a relative link, but being asp I would say there is more that gets added after the ? server side. without seeing the page and in action im not sure how much more help I can be.
When you click the link does it automatically produce the popup to save?
It could also call javascript but again i would need the whole pages source and to see what happens
My CodeBank Submissions
- Listbox with transparency and picture support - Click Here
- Check for a true internet connection - Click Here
- Open Cash drawer connected to receipt printer - Click Here
- Custom color and size border around form - Click Here
- Upload file to website without user logins, includes PHP - Click Here
- List All Removable USB Storage Devices - Click Here
- Custom On/Off Slide Control - Click Here
- Insert multiple rows of data into one database table using parameters - Click Here
- Trigger USB/Serial Cash Drawer - Click Here
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|