dcsimg
Results 1 to 14 of 14

Thread: dont know how to deal with windows messages - apologies if it's obvious

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2014
    Posts
    8

    Exclamation 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.

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    22,365

    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

  3. #3
    Fanatic Member
    Join Date
    Oct 2011
    Location
    Sydney, Australia
    Posts
    756

    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

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    22,365

    Re: dont know how to deal with windows messages - apologies if it's obvious

    Quote Originally Posted by bensonsearch View Post
    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

  5. #5
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,313

    Re: dont know how to deal with windows messages - apologies if it's obvious

    Quote Originally Posted by .paul. View Post
    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.

  6. #6
    Fanatic Member
    Join Date
    Oct 2011
    Location
    Sydney, Australia
    Posts
    756

    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

  7. #7

    Thread Starter
    New Member
    Join Date
    Mar 2014
    Posts
    8

    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!!

  8. #8
    Fanatic Member
    Join Date
    Oct 2011
    Location
    Sydney, Australia
    Posts
    756

    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

  9. #9

    Thread Starter
    New Member
    Join Date
    Mar 2014
    Posts
    8

    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")

  10. #10
    Fanatic Member
    Join Date
    Oct 2011
    Location
    Sydney, Australia
    Posts
    756

    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

  11. #11

    Thread Starter
    New Member
    Join Date
    Mar 2014
    Posts
    8

    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.

  12. #12
    Fanatic Member
    Join Date
    Oct 2011
    Location
    Sydney, Australia
    Posts
    756

    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

  13. #13

    Thread Starter
    New Member
    Join Date
    Mar 2014
    Posts
    8

    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?

  14. #14
    Fanatic Member
    Join Date
    Oct 2011
    Location
    Sydney, Australia
    Posts
    756

    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
  •  



Featured


Click Here to Expand Forum to Full Width