msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

VB6 newbie over his head! httpRequest

 
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax
Author Message
hAgGbArT



Joined: 04 Oct 2007
Posts: 1

PostPosted: Wed May 23, 2007 3:29 pm    Post subject: VB6 newbie over his head! httpRequest Reply with quote

Hi;
I am upgrading a VB6 macro in Microsoft Excel. Currently there is a code that
transmits an url through an Internet Explorer object and retrieves the title
of the page. (The url contains a sql query, and the result is printed in the
title.)
The current code for this i at the end of the post.
My problem is that this doesn't work in windows Vista with Outlook 2007. Is
there another way to do this? I am thinking httprequest- httpresponse, but I
have no Idea how this works.
Can anyone help me?

--- code start ---
Set ie = CreateObject("InternetExplorer.Application")

t = Timer
With ie
.visible = False
.Silent = True
.Navigate url
Do Until Not .Busy Or Timer - t > 30
DoEvents
Loop
'MsgBox ie.Document.Title
GetWebInfo = ie.Document.Title
.Quit
End With
Set ie = Nothing
--- code end ---

Archived from group: microsoft>public>vb>syntax
Back to top
View user's profile Send private message
Rajneesh Noonia



Joined: 04 Oct 2007
Posts: 1

PostPosted: Thu May 24, 2007 5:33 am    Post subject: Re: VB6 newbie over his head! httpRequest Reply with quote

On May 23, 5:29 pm, "hAgGbArT" wrote:
> Hi;
> I am upgrading a VB6 macro in Microsoft Excel. Currently there is a code that
> transmits an url through an Internet Explorer object and retrieves the title
> of the page. (The url contains a sql query, and the result is printed in the
> title.)
> The current code for this i at the end of the post.
> My problem is that this doesn't work in windows Vista with Outlook 2007. Is
> there another way to do this? I am thinking httprequest- httpresponse, but I
> have no Idea how this works.
> Can anyone help me?
>
> --- code start ---
> Set ie = CreateObject("InternetExplorer.Application")
>
> t = Timer
> With ie
> .visible = False
> .Silent = True
> .Navigate url
> Do Until Not .Busy Or Timer - t > 30
> DoEvents
> Loop
> 'MsgBox ie.Document.Title
> GetWebInfo = ie.Document.Title
> .Quit
> End With
> Set ie = Nothing
> --- code end ---


Please find the code to get title of web page..

Private Function GetTitle(ByVal URL As String) As String
Dim pHTMLDocument As MSHTML.HTMLDocument
Dim pIHTMLDocument As IHTMLDocument
Dim pLngWait As Long

Set pHTMLDocument = New MSHTML.HTMLDocument
pLngWait = 10
Set pIHTMLDocument = pHTMLDocument.createDocumentFromUrl(URL, "")
Do While (1)
If pHTMLDocument.readyState = "complete" Then
While (pLngWait > 0)
DoEvents
pLngWait = pLngWait - 1
Wend
Exit Do
End If
DoEvents
Loop
DoEvents
GetTitle = pIHTMLDocument.Title
End Function

Let me know if this helps

Regards
Rajneesh Noonia
Back to top
View user's profile Send private message
hAgGbArT via VBMonster.co



Joined: 04 Oct 2007
Posts: 1

PostPosted: Fri May 25, 2007 12:24 am    Post subject: Re: VB6 newbie over his head! httpRequest Reply with quote

Thank you!
This seems to do the trick. I will have to do some more compatibility testing
before I'm shure though.
One thing, Once in a while it returns an empty title, Is this because the
code is faster than the reply? should I add a wait command somewhere?


Rajneesh Noonia wrote:
>> Hi;
>> I am upgrading a VB6 macro in Microsoft Excel. Currently there is a code that
>[quoted text clipped - 24 lines]
>> Set ie = Nothing
>> --- code end ---
>
>Please find the code to get title of web page..
>
>Private Function GetTitle(ByVal URL As String) As String
> Dim pHTMLDocument As MSHTML.HTMLDocument
> Dim pIHTMLDocument As IHTMLDocument
> Dim pLngWait As Long
>
> Set pHTMLDocument = New MSHTML.HTMLDocument
> pLngWait = 10
> Set pIHTMLDocument = pHTMLDocument.createDocumentFromUrl(URL, "")
> Do While (1)
> If pHTMLDocument.readyState = "complete" Then
> While (pLngWait > 0)
> DoEvents
> pLngWait = pLngWait - 1
> Wend
> Exit Do
> End If
> DoEvents
> Loop
> DoEvents
> GetTitle = pIHTMLDocument.Title
>End Function
>
>Let me know if this helps
>
>Regards
>Rajneesh Noonia

--
Message posted via http://www.vbmonster.com

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
newbie Hi, Can anyone tell me if there is a sleep command.. i.e. wait for 2 seconds then carry on with code. ben

Help for a complete newbie Hello all, I'm trying to write a macro that will run upon exiting a dropdown box in a protected word form. What I'd like to do is, when a user chooses an option in the dropdown box other than the fist choice, the text in the box is changed to bold. So f

Why this error ? (newbie question) I have a ADO DC connection with a database and in the Form_Load i have the code : Dim rs As Recordset Set rs = rs.MoveFirst <--- error message in the last line I receive the error message : "Object variable no set" Why this error ???

ExecCmd newbie question Hello all, I have a problem at our company with a very old graphics application (we made it ourselves) which displays its images by using a Reflexion Based Script (which uses VB statements). This script contains the following line to display the graphics

PLZ help newbie w/ save command I created my 1st application and deployed it. I'm able to access & open it straight from my desktop with no problem. All the information and calculations designed work flawlessly. The only problem is that when I save the form and name it to a folder for f
Post new topic   Reply to topic    msvisual.com Forum Index -> VB Syntax All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group