PDA

View Full Version : Solved: Get a Full address of a website using a macro



dansam
02-22-2007, 09:25 AM
Hi everyone, :hi:
I have a command button and a textbox1 on a user form.
In textbox1 there is a short address of a website like instead of ?Http://www.google.com ?there is only ?google.com? (or instead of ?http://www.vbaexpress.com/portal.php? there is only ?.vbaexpress.com?)
And what I want to do is:

(1) When user clicks on command button, it shows the full address of a website (as I mentioned above) in a msgbox.

(2) It also shows a msgbox which contains the title bar address . Like for google.com the title bar address (which we can found in title bar of internet explorer) is ?Google? which is like ?Google ? Microsoft Internet Explorer?
So,
Is it possible? :think: :think: :think:
And if yes then are there any suggestions for the right vba code that I should use??? :think:


Thanks, :rofl:
Dan

CBrine
02-22-2007, 09:37 AM
dansam,
For you first question, i need a little more detail.

1. What kind of error checking do want in place? What happens if someone types in www.google.com (http://www.google.com) instead of google.com?
2. What happens if an invalid address is entered? I'm not sure how to evaluate if an address is valid, but there must be a way? Maybe pinging the server to see if it's valid?

3. For your second question, I'm not sure if that's possible, but I have couple of ideas that I can test and see if they work.
HTH
Cal

dansam
02-22-2007, 09:41 AM
Hi cbrine,

1. What kind of error checking do want in place? What happens if someone types in www.google.com (http://www.google.com/) instead of google.com?
2. What happens if an invalid address is entered? I'm not sure how to evaluate if an address is valid, but there must be a way? Maybe pinging the server to see if it's valid?

No not that matter, but I just want to get the full address for my personal use.
Any suggestions?
Regards,
Dan

CBrine
02-22-2007, 10:01 AM
Dan,
Give this a try.

HTH
Cal

stanl
02-22-2007, 10:02 AM
you can use the InternetExplorer.Application Object. Use the .navigate method to browse, if successful then parse the .url and .title properties. If not successful whatever url is returned can be gleaned by using instr().
Stan

dansam
02-22-2007, 07:51 PM
Hi cbrine,
thanks for your help , I got the solution for both que.
here it is :
Private Sub wb_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
Label1.Caption = wb.LocationURL
Label2.Caption = wb.LocationName
End Sub
It worked.
thanks,
dan

CBrine
02-23-2007, 07:38 AM
Sweet,
Glad I could help you out dansam. Don't forget to mark the thread as solved!!!

Cal

dansam
02-23-2007, 08:19 AM
ya,
thanks