cellulargnome
New Member
- Joined
- Mar 30, 2017
- Messages
- 15
First of all let me apologize for the fact questions almost the same as this have been posted to death, I just haven't found a solution that meets my needs.
I need to pull a short line of text from a web page and display it in a userform. The page I need text from is VERY small.
I'm able to post the given text to a form an a different page with the below.
I have the Microsoft Internet Controls ref added to the vba project. and the above works to get the text posted.
What I am now having trouble with is seeing this text without having web page open.
For now having looked around for hours I've settled for using the web browser control in a user form just to display the actual page, it's not pretty and not ideal.
What I want is to post the text from that page on the same userform I have to update it.
I tried to paste the HTML I'm looking at but MrExcel seems to process it in and out of code tags and even commented out it still runs so you see a table.
The only way I see the ID the text I want is with it's class
<td height="31" align="center" bgcolor="#4F6C8A" class="THECLASS">THE TEXT TO DISPLAY</td>
I'll post the HTML in tags anyway (maybe it'll show up in the page source)
Nothing useful above or below this table in the code, I did say it's a small page. A little bit of CSS and bit of JAVA to refresh the page at set intervals. Page contains the table above and nothing else.
It would be a great help if somebody had something that would work for me.
I've tried a few times to utilize the first bit of code to grab the text and add it to a string that I can ref in a label but it keeps failing when I run it. It's fails when I attempt to set a string to the value of IE.Document.<wbr>getElementsByClassName("THECLASS"). I've tried adding .InnerHtml and .InnerText but it still fails.
Many thanks in advance for any solutions.
I need to pull a short line of text from a web page and display it in a userform. The page I need text from is VERY small.
I'm able to post the given text to a form an a different page with the below.
Code:
Private Sub btnSubmit_Click()
Dim IE As SHDocVw.InternetExplorer
Set IE = New SHDocVw.InternetExplorer
IE.Visible = False
IE.Navigate "URLHERE"
Do
DoEvents
Loop Until IE.ReadyState = 4
Call IE.Document.GetElementByID("<wbr>ELEMENTID").SetAttribute("<wbr>value", TEXTBOX.Value)
Set AllInputs = IE.Document.<wbr>getElementsByTagName("input")
For Each hyper_link In AllInputs
If hyper_link.Name = "button" Then
hyper_link.Click
Exit For
End If
Next
Do
DoEvents
Loop Until IE.ReadyState = 3
Do
DoEvents
Loop Until IE.ReadyState = 4
IE.Quit
Unload Me
End Sub
I have the Microsoft Internet Controls ref added to the vba project. and the above works to get the text posted.
What I am now having trouble with is seeing this text without having web page open.
For now having looked around for hours I've settled for using the web browser control in a user form just to display the actual page, it's not pretty and not ideal.
What I want is to post the text from that page on the same userform I have to update it.
I tried to paste the HTML I'm looking at but MrExcel seems to process it in and out of code tags and even commented out it still runs so you see a table.
The only way I see the ID the text I want is with it's class
<td height="31" align="center" bgcolor="#4F6C8A" class="THECLASS">THE TEXT TO DISPLAY</td>
I'll post the HTML in tags anyway (maybe it'll show up in the page source)
Code:
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="31" align="center" bgcolor="#4F6C8A" class="THECLASS">THE TEXT TO DISPLAY</td>
</tr>
</table>
</td>
</tr>
</table>
Nothing useful above or below this table in the code, I did say it's a small page. A little bit of CSS and bit of JAVA to refresh the page at set intervals. Page contains the table above and nothing else.
It would be a great help if somebody had something that would work for me.
I've tried a few times to utilize the first bit of code to grab the text and add it to a string that I can ref in a label but it keeps failing when I run it. It's fails when I attempt to set a string to the value of IE.Document.<wbr>getElementsByClassName("THECLASS"). I've tried adding .InnerHtml and .InnerText but it still fails.
Many thanks in advance for any solutions.