?
Solved

VBA to check if an IE tag class exists

Posted on 2012-12-21
2
Medium Priority
?
2,839 Views
Last Modified: 2013-11-19
I've created code in MS Access that reads and stores various data elements from a web page.

But, sometimes, that page (result from filling out a form) does not have any data. In which case, a message shows up.

Here's a portion of the HTML:

<body onLoad="onLoad()">
<div id="wrap">
  <!--header start -->
  <div id="custom_header">
        <div style="width:370px; text-align:left; margin:auto 0px; padding-top:10px; padding-left:10px;">
      <p style="font-size:24pt; font-weight:bold; color: #fff; text-align:center; font-family: Tahoma, Geneva, sans-serif; line-height:24pt">
        My First Line      </p>
      <p style="font-size:18pt; font-weight:700; color: #fff; text-align:center; font-family: Tahoma, Geneva, sans-serif; padding-top:5px">
        My Second Line        <br />
        <br/>
      </p>
      <br />
    </div>
      </div>
  <!--header end --> 


<div id="main">

<div id="maincontent">
<div class="ui-corner-all warning">
	<h3>Your Business Phone Number <u>8005551212</u> is not being found!</h3>
</div><br />

Open in new window



This tag: <div class="ui-corner-all warning">

ONLY shows up in the document when the form returns no data.

what vba can I use to search the IE DOM to see if that tag/class exists?)

I feel like it should be something like one of these...

.getElementByID
.getElementsByTagName
.getElementsByClassName

But, I'm stumped.

Any help?
0
Comment
Question by:Kaprice
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 29

Accepted Solution

by:
IrogSinta earned 2000 total points
ID: 38714966
I found something that maybe you could incorporate:
Dim html As Object ' MSHTML.HTMLDocument
Dim resultClasses As Object 
Dim resultClass As Object 

Set html = CreateObject("htmlfile") ' New MSHTML.HTMLDocument
html.body.innerHTML = ' String variable containing your result

Set resultClasses = html.getElementsByTagName("div") 
For Each resultClass In resultClasses 
    If resultClass.getAttribute("class") = "ui-corner-all warning" Then 
        Msgbox "Found"
        Exit For 
    End If 
Next resultClass 

Open in new window

0
 

Author Closing Comment

by:Kaprice
ID: 38714974
That's the ticket. Thanks!
0

Featured Post

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question