How to click on "Create Issue" button in Excel VBA - html

Hi i'm trying to get the "Create an Issue" button to click after filling out a form online. The form fills correctly I just need it to do the final piece and click on the "Create Issue".
Here's my setup and code
Microsoft Excel 2016 32bit
VBA:
Option Explicit
Sub Waiting()
Application.Wait (Now + TimeValue("0:00:2"))
End Sub
Sub IE_Wait(IE As InternetExplorer)
With IE
While .Busy Or .ReadyState <> READYSTATE_COMPLETE
DoEvents
Call Waiting
' SendKeys "{ENTER}"
Wend
While .Document.ReadyState <> "complete"
DoEvents
Call Waiting
'SendKeys "{ENTER}"
Wend
End With
End Sub
Sub FindAndTerminate(ByVal strProcName As String)
Dim objWMIService, objProcess, colProcess
Dim strComputer, strList
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = '" & strProcName & "'")
If colProcess.Count > 0 Then
For Each objProcess In colProcess
On Error Resume Next
objProcess.Terminate
Next objProcess
End If
End Sub
Public Sub make_tickets_with_me()
Dim IE As InternetExplorer
Dim HTMLdoc As HTMLDocument
Dim x, Site, ASIN_1, ASIN_2, ASIN_3, ASIN_4, ASIN_5 As String
Dim ws As Worksheet
Dim e
Dim y, lLastRow As Long
' Kill any currently running Explorer Windows
FindAndTerminate "iexplore.exe"
Application.DisplayAlerts = False
Application.EnableEvents = False
Application.ScreenUpdating = False
Set IE = New InternetExplorerMedium
With ThisWorkbook
lLastRow = Worksheets("ASINs").Cells(Rows.Count, "A").End(xlUp).Row 'Count total Asins
x = 2
For x = 2 To lLastRow
Debug.Print x
ASIN_1 = Worksheets("ASINs").Range("A" & x).Value
ASIN_2 = Worksheets("ASINs").Range("A" & x + 1).Value
ASIN_3 = Worksheets("ASINs").Range("A" & x + 2).Value
ASIN_4 = Worksheets("ASINs").Range("A" & x + 3).Value
ASIN_5 = Worksheets("ASINs").Range("A" & x + 4).Value
Site = "https://sim.amazon.com/issues/create?assignedFolder=5aec25c2-1135-4d36-b751-37d967c0a83e&title=Zappos+Unsellable+Test&description=Below+is+a+list+of+5+asins+that+are+unsellable%3A%20%0D%0A%0D%0A" + ASIN_1 + "%0D%0A" + ASIN_2 + "%0D%0A" + ASIN_3 + "%0D%0A" + ASIN_4 + "%0D%0A" + ASIN_5 + "%0D%0A%0D%0A&descriptionContentType=text%2Fplain&extensions%5Btt%5D%5Bimpact%5D=4&extensions%5Btt%5D%5Bcategory%5D=&authorizations%5B%5D=BREAK&authZCompression=v1"
x = x + 4
' Debug.Print ASIN_1 & ASIN_2 & ASIN_3 & ASIN_4 & ASIN_5
' Debug.Print x
' Debug.Print Site
''' BEGIN INTERACTION WITH IE
Set IE = New InternetExplorerMedium
With IE
.Visible = True
.Left = 25
.Top = 25
.Height = 700
.Width = 1300
AppActivate ("Internet Explorer")
.Navigate Site
IE_Wait IE
Call Waiting
IE_Wait IE
Call Waiting
Set e = IE.Document.getElementsByTagName("span")
->>>>>>>If e.innerText = "Create an issue In Zappos Unsellable: Tickets" Then
e.parentElement.Click
Exit For
End If
'Set e = IE.Document.getElementsByClassName("create")(0)
'e.Click
' SendKeys "{NUMLOCK}"
Call Waiting
.Quit
End With
Next 'Loop for x=2 to lLastRow, Adds 4 to x, then Next adds 1 to total of 5 per iteration
ThisWorkbook.Worksheets("Buttons").Activate
MsgBox ("Tickets Created :)")
End With
End Sub
I've added an arrow to where the error is.
Here's the Inspect for the button I want to click
</div>
<div class="clearfix"></div>
<script type="jsv/50_"></script></div></section>
<section class="wizard-step " id="wizard-step-2" data-wizard-step="2"><div data-module-name="App.Views.CreateWizardStep" data-template="#create-wizard-step-template"><script type="jsv#112_"></script>
<div class="form-actions">
<div class="view-state-initialized-visible" data-view="create">
<button class="btn btn-primary btn-large" type="submit" data-csm-counter="createViewCreateButton">
<span style="display: inline;" data-link="visible{:!~isUndefined(issue.assignedFolder)}"><span id="view-tag-157" data-module-name="App.Views.FolderDisplayView" data-template="undefined"><script type="jsv#170_"></script><span style="display: inline;" data-name="folder-label-completed-text" data-link="visible{:state == 'completed'}">
<script type="jsv#219^"></script><script type="jsv#308_"></script>
<script type="jsv#388^"></script>Zappos Unsellable: Tickets
Create an issue in
<script type="jsv/388^"></script>
<script type="jsv/308_"></script><script type="jsv/219^"></script>
</span><span style="display: none;" data-link="visible{:state == 'loading'}">
<script type="jsv#172_"></script><i class="icon-spinner"></i><script type="jsv/172_"></script>
Loading folder...
</span><span style="display: none;" data-link="visible{:state == 'errored'}">
Could not find folder
</span><span style="display: none;" data-link="visible{:state == 'empty'}">
Folder not specified
</span><script type="jsv/170_"></script></span>
</span>
<span style="display: none;" data-link="visible{:~isUndefined(issue.assignedFolder)}">
Create an issue
</span>
</button>
<div class="alert alert-error pull-right" style="display: none;" data-link="visible{:!state.isValid}">
Please correct the errors above
</div>
</div>
<div class="view-state-loading-visible alert alert-info" data-view="create">
<script type="jsv#113_"></script><i class="icon-spinner"></i><script type="jsv/113_"></script>
Creating your issue...
</div>
<div class="view-state-errored-visible alert alert-error" data-view="create">
<strong>There was an error creating your issue:</strong>
<div data-link="html{>state.createError}"></div>
<button class="btn btn-primary pull-right" type="submit" data-csm-counter="createViewTryAgainButton">
Try again
</button>
<div class="clearfix"></div>
</div>
<div class="view-state-redirecting-visible alert alert-success" data-view="create">
Redirecting you to
<a href="/issues/undefined" data-link="href{:'/issues/' + issue.id} data-issue-id{htmlAttr:issue.id}" data-issue-id="">
your new issue
</a>
</div>enter code here
Any help would be appreciated i'm trying to edit another persons VBA that left.

You can try a combination of css selectors
ie.document.querySelector("button[data-csm-counter=createViewTryAgainButton]").click

Related

Cannot login to website using a macro and vba

I am trying to login to a website using the following which works on different url
Sub Mylogin()
Dim MyHTML_Element As IHTMLElement
Dim MyURL As String
On Error GoTo Err_Clear
MyURL = "MYURL"
ie.Silent = True
ie.Navigate MyURL
ie.Visible = True
Do
Loop Until ie.ReadyState = READYSTATE_COMPLETE
Set HTMLDoc1 = ie.Document
HTMLDoc1.all.Email.Value = "MYEMAIL" 'Enter your email id here
HTMLDoc1.all.Password.Value = "MYPASSWD" 'Enter your password here
For Each MyHTML_Element In HTMLDoc1.getElementsByTagName("input")
If MyHTML_Element.Type = "submit" Then MyHTML_Element.Click: Exit For
Next
Err_Clear:
If Err <> 0 Then
Err.Clear
Resume Next
End If
End Sub
The submit button is under div and I dont know if this is the problem. The html login part is the following
<div id="login-area-main">
<div id="user">
<div id="username">
<input name="p$lt$ctl01$LogonFormIndice$loginElem$UserName" type="text" maxlength="50" id="p_lt_ctl01_LogonFormIndice_loginElem_UserName" placeholder="E-mail" />
<span class="CMSValidator"><span id="p_lt_ctl01_LogonFormIndice_loginElem_rfvUserNameRequired" title="Please enter a user name." class="profile-validator validator error-message" style="display:none;">
</span></span>
</div>
</div>
<div id="pass">
<div id="password">
<input name="p$lt$ctl01$LogonFormIndice$loginElem$Password" type="password" maxlength="20" id="p_lt_ctl01_LogonFormIndice_loginElem_Password" placeholder="Password" />
<span class="CMSValidator"><span id="p_lt_ctl01_LogonFormIndice_loginElem_rfvPasswordRequired" class="profile-validator validator error-message" style="visibility:hidden;">
</span></span>
</div>
</div>
<div id="pass-forgot">
<p>Forgot Password</p>
</div>
<div id="submit-button">
<a id="p_lt_ctl01_LogonFormIndice_loginElem_btnLogon" class="buyBtn button" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("p$lt$ctl01$LogonFormIndice$loginElem$btnLogon", "", true, "p_lt_ctl01_LogonFormIndice_MiniLogon", "", false, true))"></a>
</div>
Do I have to do something with
MyHTML_Element.Type = "submit"
And put inside the div id?
I notice that the HTMLDoc1 is Empty..! should it be empty?
I tried the following but nothing displayed or clicked
Const Url$ = "URL"
Dim UserName As String, Password As String, LoginData As Worksheet
Set LoginData = ThisWorkbook.Worksheets("MySheet")
UserName = LoginData.Cells(1, "K").Value
Password = LoginData.Cells(2, "K").Value
Dim iex As Object
Set iex = CreateObject("InternetExplorer.Application")
With iex
.Navigate Url
ieBusy iex
.Visible = True
Dim oLogin As Object, oPassword As Object
iex.Document.querySelector(".username [id='p_lt_ctl01_LogonFormIndice_loginElem_UserName']").Focus
Set oLogin = iex.Document.querySelector(".username [id='p_lt_ctl01_LogonFormIndice_loginElem_UserName']").Value = ""
Set oPassword = iex.Document.querySelector(".password [type=password]").Value = ""
oLogin.Value = UserName
oPassword.Value = Password
iex.Document.getElementById("submit-button").Click
End With
It asks about an Object on
iex.Document.querySelector("id='p_lt_ctl01_LogonFormIndice_loginElem_UserName']").Focus
I am confused by where your actual problem is.
There is an id for the submit
ie.document.getElementById("submit-button").click ' 0r .submit
For username:
ie.document.querySelector("[id='p_lt_ctl01_LogonFormIndice_loginElem_UserName']").value = ""
For password
ie.document.querySelector("[type=password]").value = ""
When entering values it sometimes helps to use .Focus on the element before assigning the .value.
Public Sub GetInfo()
Dim ie As New InternetExplorer
With ie
.Visible = True
.navigate URL
While .Busy Or .readyState < 4: DoEvents: Wend
With .document.querySelector("[id='p_lt_ctl01_LogonFormIndice_loginElem_UserName']")
.Focus
.value = ""
End With
With .document.querySelector("[type=password]")
.Focus
.value = ""
End With
.document.getElementById("submit-button").click
While .Busy Or .readyState < 4: DoEvents: Wend
Stop
'Quit
End With
End Sub

Extracting div class information from website with VBA

I've been trying to scrape the following page for research purposes: http://www.brazil4export.com/en/pesquisa/resultado/?page=1&
A piece of HTML I want to get information from is the following:
<div class="panel panel-default">
<div class="panel-heading" data-activity="22196 - Manufacturer" data-products='["Products", "Information"]' data-range="Value" data-contact="Person" data-site="www.website.com.br" data-emails="name#example.com" data-phones="Phone" data-address="Street / City" data-countries='["Country1", "Country2"]' data-name="ACME Corp.">
<h3 class="panel-title">
<button class="btn btn-link" data-toggle="modal" data-target="#company-modal">
ACME Corp.
</button>
</h3>
<button class="btn btn-primary btn-lg pull-right" data-toggle="modal" data-target="#company-modal">
<i class="icon-plus"></i>
</button>
</div>
</div>
For each result on the page, there's a <div class="panel panel-default">, just as the above, and I want to get the data-name and data-site information from each of them. This is what I've tried, so far:
Sub useClassnames()
Dim element As IHTMLElement
Dim elements As IHTMLElementCollection
Dim ie As InternetExplorer
Dim html As HTMLDocument
'open Internet Explorer in memory, and go to website
Set ie = New InternetExplorer
ie.Visible = True
ie.navigate "http://www.brazil4export.com/en/pesquisa/resultado/?page=1&"
'Wait until IE has loaded the web page
Do While ie.READYSTATE <> READYSTATE_COMPLETE
Application.StatusBar = "Loading Web page …"
DoEvents
Loop
Set html = ie.document
Set elements = html.getElementsByClassName("panel panel-default")
Dim erow As Long
For Each element In elements
If element.className = "data-name" Then
erow = Sheet1.Cells(Rows.count, 1).End(xlUp).Offset(1, 0).Row
Cells(erow, 2) = html.getElementsByClassName("data-name").innerText
End If
If element.className = "data-site" Then
erow = Sheet1.Cells(Rows.count, 1).End(xlUp).Offset(1, 0).Row
Cells(erow, 3) = html.getElementsByClassName("data-site").innerText
End If
Next element
End Sub
It doesn't work, but doesn't show me any errors as well.
Run this and you will have all the results:
Sub WebData()
Dim http As New XMLHTTP60, html As New HTMLDocument
Dim source As Object
With http
.Open "GET", "http://www.brazil4export.com/en/pesquisa/resultado/?page=1&", False
.send
html.body.innerHTML = .responseText
End With
For Each source In html.getElementsByClassName("panel-heading")
x = x + 1: Cells(x, 1) = source.getAttribute("data-Name")
Cells(x, 2) = source.getAttribute("data-site")
Next source
End Sub
Make sure to add "Microsoft Html Object Library" and "Microsoft xml" to the reference library. See the picture of the results:

Send data to a webform using MS Access VBA

I am trying to send data from an Access DB to a website http://www.lee.vote/voters/check-your-registration-status/. I'm able to use similar code (below) to send data to a different website, but I can't figure out why it doesn't work for this website.
The HTML from what I'm trying to fill in:
<div id="FindVoterForm">
<div id="IntroText">
<h1 style="text-align: center; margin-bottom: 3px;">Voter Information in <span id="MainCounty">Lee</span> County</h1>
<h2 style="text-align: center; margin-top: 3px; margin-bottom: 3px;">Sample Ballots and Voting Locations</h2>
<span class="style1" style="margin-bottom: 0px;">Complete the form to see:</span><ul style="margin-top: 0px;">
<li class="style1"><b>Where to vote on election day</b></li>
<li class="style1"><b>Sample ballots</b></li>
<li class="style1"><b>Upcoming elections</b></li>
</ul>
<p class="style2" style="margin-bottom: 0px;">
You'll also be able to:</p>
<ul style="margin-top: 0px;">
<li class="style2">Request a mail ballot</li>
<li class="style2">Review/update your voter registration information</li>
<li class="style2">Check the status of your mail ballot</li>
<li class="style2">Review your voting activity for the past 12 months</li>
</ul>
<div id="NotRegistered" style="font-size: small;">If you are not registered to vote please fill out our voter registration form</div><br>
<i><b style="text-decoration: underline;">All items are required</b></i>.
</div>
<div class="voterForm">
<div class="voterFormLine"><div>1.</div><div>Voter's Last Name</div><div><input title="Please enter your last name." id="NameID" type="text" size="10" maxlength="35" value=""></div>
</div><div class="voterFormLine"><div>2.</div><div>Voter's Birth Date</div><div><input title="Please enter your birth date (MM/DD/YYYY)." id="BirthDate" type="text" size="10" maxlength="10" value="">
<br>MM/DD/YYYY</div></div><div class="voterFormLine"><div>3.</div>
<div><a title="House Number" href="https://www.voterfocus.com/VFVoterGlossery.php?term=House Number" target="_blank">House Number</a> of Voter's Residence Address</div>
<div><input title="Please enter your house street number." id="StNumber" type="text" size="10" maxlength="10" value=""></div>
</div>
<div> </div>
</div>
<div><div style="text-align: center;"><h2 id="MoreVoter" style="display: none;"><b></b></h2>
<button id="ButtonForm" onclick="ButtonForm_onclick()" type="button" value="Submit">Submit</button></div>
</div>
</div>
The VBA code:
'creates a new internet explorer window
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
'opens Lee County registration check
With IE
.Visible = True
.navigate "http://www.lee.vote/voters/check-your-registration-status/"
End With
'waits until IE is loaded
Do Until IE.ReadyState = 4 And Not IE.busy
DoEvents
Loop
'sends data to the webpage
Call IE.Document.getelementbyid("NameID").setattribute("value", Last_Name)
Call IE.Document.getelementbyid("BirthDate").setattribute("value", Date_of_Birth.Value)
Call IE.Document.getelementbyid("StNumber").setattribute("value", Street_Number.Value)
'"clicks" the button to display the results
IE.Document.getelementbyid("ButtonForm").Click
Any help?
The HTML snippet you provided belongs to iframe <iframe id="dnn_ctr1579_View_VoterLookupFrame" src="https://www.electionsfl.org/VoterInfo/vflookup.html?county=lee" width="100%" height="2000" frameborder="0"></iframe>, so you should navigate to URL https://www.electionsfl.org/VoterInfo/vflookup.html?county=lee instead of http://www.lee.vote/voters/check-your-registration-status/.
I navigated https://www.electionsfl.org/VoterInfo/vflookup.html?county=lee in Chrome and checked XHR logged after I submit the data via Developer Tools (F12), Network tab:
Seems that is simple POST XML HTTP request with payload in JSON format, like:
{'LastName':'Doe', 'BirthDate':'01/01/1980', 'StNumber':'10025', 'County':'lee', 'FirstName':'', 'challengeValue':'', 'responseValue':''}
That XHR uses no cookies or any other authorization data neither in headers nor payload, so I tried to reproduce the same request using the following code:
Option Explicit
Sub Test_Submit_VoterInfo()
Dim sLastName As String
Dim sBirthDate As String
Dim sStNumber As String
Dim sFormData As String
Dim bytFormData
Dim sContent As String
' Put the necessary data here
sLastName = "Doe"
sBirthDate = "01/01/1980"
sStNumber = "10025"
' Combine form payload
sFormData = "{" & _
"'LastName':'" & sLastName & "', " & _
"'BirthDate':'" & sBirthDate & "', " & _
"'StNumber':'" & sStNumber & "', " & _
"'County':'lee', " & _
"'FirstName':'', " & _
"'challengeValue':'', " & _
"'responseValue':''" & _
"}"
' Convert string to UTF-8 binary
With CreateObject("ADODB.Stream")
.Open
.Type = 2 ' adTypeText
.Charset = "UTF-8"
.WriteText sFormData
.Position = 0
.Type = 1 ' adTypeBinary
.Position = 3 ' skip BOM
bytFormData = .Read
.Close
End With
' Make POST XHR
With CreateObject("MSXML2.XMLHTTP")
.Open "POST", "https://www.electionsfl.org/VoterInfo/asmx/service1.asmx/FindVoter", False, "u051772", "mar4fy16"
.SetRequestHeader "Content-Length", LenB(bytFormData)
.SetRequestHeader "Content-Type", "application/json; charset=UTF-8"
.Send bytFormData
sContent = .ResponseText
End With
' Show response
Debug.Print sContent
End Sub
The response for me is {"d":"[]"}, the same as in browser, but unfortunately I can't check if it processed on the server correctly, since I have no valid voter record data.
This is the answer that I came up with after the (much needed) help determining that I was not really navigating to the right webpage for the form:
'creates a new internet explorer window
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
'opens Lee County registration check
With IE
.Visible = True
.navigate "https://www.electionsfl.org/VoterInfo/vflookup.html?county=lee"
End With
'waits until IE is loaded
Do Until IE.ReadyState = 4 And Not IE.busy
DoEvents
Loop
x = Timer + 2
Do While Timer < x
DoEvents
Loop
'sends data to the webpage
Call IE.Document.getelementbyid("NameID").setattribute("value", Last_Name.Value)
'formats DOB to correct output
Dim DOBMonth As Integer
Dim DOBDay As Integer
Dim DOBYear As Integer
DOBMonth = Month(Date_of_Birth.Value)
DOBDay = Day(Date_of_Birth.Value)
DOBYear = Year(Date_of_Birth.Value)
If DOBMonth < 10 Then
Call IE.Document.getelementbyid("BirthDate").setattribute("value", "0" & DOBMonth & "/" & DOBDay & "/" & DOBYear)
Else
Call IE.Document.getelementbyid("BirthDate").setattribute("value", DOBMonth & "/" & DOBDay & "/" & DOBYear)
End If
Call IE.Document.getelementbyid("StNumber").setattribute("value", Street_Number.Value)
'"clicks" the button to display the results
IE.Document.getelementbyid("ButtonForm").Click

Input TextArea and Output TextArea and Save To

I've written up a quick hta for quick actions via button: copy to clipboard, message boxes, and run specific files. Now I'm trying figure out how to add:
2 textarea boxes
TextArea1 - Type text inside
Submit button to save textarea1 to local file and load to textarea2
TextArea2 - will display text from saved local file from textarea1
Thanks for your time and consideration
<html>
<head>
<title>**All Access QL v1.0**</title>
<HTA:APPLICATION
ID="TestHTA"
APPLICATIONNAME="TestHTA"
ICON = "C:\L.S.L._QL_HTAv1.0\Media\RazerIcon.ico"
BORDER="thin"
MINIMIZEBUTTON="no"
MAXIMIZEBUTTON="no"
SCROLL="no"
SINGLEINSTANCE="no"
SysMenu="no"
WINDOWSTATE="normal">
<link rel="stylesheet" href="styles.css" media="all" type="text/css"/>
<SCRIPT LANGUAGE="VBScript">
Sub Window_onLoad
window.resizeTo 510,510
End Sub
Sub ExitProgram
window.close()
End Sub
Sub fileupdate
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFolder "C:\CopyFromLocation1","C:\CopyToLocation1", True
End Sub
Sub lotsiu
strMessage = "Line 1" & vbNewLine & "Line 2"
Set objWord = CreateObject("Word.Application")
With objWord
.Visible = False
.Documents.Add
.Selection.TypeText strMessage
.Selection.WholeStory
.Selection.Copy
.Quit False
End With
End Sub
Sub faqmbrPhonumuse
msgbox "Line 1" & vbNewLine & "Line 2"
End Sub
Sub appword
Set objShell = CreateObject("Wscript.Shell")
objShell.Run "WINWORD.exe"
End Sub
sub Window_onLoad()
set oFSO=CreateObject("Scripting.FileSystemObject")
set oFile=oFSO.OpenTextFile("Test.txt",1)
text=oFile.ReadAll
document.all.ScriptArea.value=text
oFile.Close
End sub
Sub Submitarea
Set oFile = fso.OpenTextFile( "TextArea.txt",8,true)
sTxtarea = document.all("Txtarea").Value
oFIle.Write sTxtarea & vbCRLF
MsgBox "Your text has been added to TextArea.txt", 64,"Textarea Input"
oFile.close
End Sub 'Submitarea
</SCRIPT>
</head>
<body>
<div id="Title">
<b>PSC Quick Access</b>
<input id="checkButton" class="upbutton" type="button" value="UPDATE" name="run_button" onClick="fileupdate" align="right">
<input id="checkButton" class="upbutton" type="button" value="EXIT" name="run_button" onClick="ExitProgram" align="right">
</div>
<div id="SubTitle">
Email- Phone Number
</div>
<div id="Icon">
</div>
<br>
<div id="ContentBox">
<b>Fax Temps (Click and Paste)</b>
</div>
<input id="checkButton" class="faxbutton" type="button" value="Button 1" name="btn_Next" onClick="button1" align="right">
<br>
<div id="ContentBox">
<b>Apps (Click To Start)</b>
</div>
<input id="checkButton" class="appbutton" type="button" value="Notepad" name="run_button" onclick="appnotepad" align="right">
<input id="checkButton" class="appbutton" type="button" value="Word" name="run_button" onClick="appword" align="right">
<br>
<div id="ContentBox">
<b>FAQs (Click for Info)</b>
</div>
<input id="checkButton" class="faqbutton" type="button" value="Num For Mbr" name="run_button" onClick="faqmbrPhonumuse" align="right">
<br>
<div id="ContentBox">
<b>Lotus Temps (Click and Paste)</b>
</div>
<input id="checkButton" class="lotbutton" type="button" value="SIU" name="btn_Next" onClick="lotsiu" align="right">
</div>
<form method="POST">
<TEXTAREA style="
Height:193;
Width:100%;
font-Size:12;
color:#000000;
background-color:#ffffe7;
font-weight:normal;
font-family:MS Sans Serif"
TITLE=""
NAME=Txtarea TABORDER=2 WRAP=PHYSICAL>The contents of this text area will be written to C:\TextArea.doc when you click submit.******First time submit is click if file has not been created it will be create automatically daily log with system date appended at the end******and will append data to top of file with prefix of system time******Line at end of margin will have hard return when text is at the end******And get and display new changed text in the lower text box and diplayed******Lower textarea has scroll and can be highlighted, but not editable"</TEXTAREA>
<input type="button" value="Submit" onclick="Submitarea">
<input type="reset" value="Clear">
<br><br>
<textarea name="ScriptArea" rows=10 cols=70></textarea><p>
</div>
</body>
EDIT : 09/03/2015 Try something like that :
<html>
<Title>How to open and read the log file with HTA</Title>
<head>
<HTA:APPLICATION
ICON="cmd.exe"
APPLICATIONNAME = "How to open and read the log file with HTA"
BORDER="dialog"
BORDERSTYLE="complex"
WINDOWSTATE="maximize"
>
<style>
body{
background-color: Black;
}
</style>
</head>
<script type="text/Vbscript">
Option Explicit
Dim File,fso,oFile,objShell
Set fso = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
File = "C:\Test_" _
& Month(Date) & "_" & Day(Date) & "_" & Year(Date) _
& ".txt"
'***********************************************************
Sub LoadMyFile()
txtBody.Value = LoadFile(File)
End Sub
'***********************************************************
Function LoadFile(File)
On Error Resume Next
Dim fso,F,ReadMe,strError
Set fso = CreateObject("Scripting.FileSystemObject")
Set F = fso.OpenTextFile(File,1)
If Err.Number <> 0 Then
strError = "<center><b><font color=Red>The file "& File &" dosen't exists !</font></b></center>"
myDiv.InnerHTML = strError
Exit Function
End If
ReadMe = F.ReadAll
LoadFile = ReadMe
End Function
'***********************************************************
Sub Clear()
txtBody.Value = ""
myDiv.InnerHTML = ""
Txtarea.Value = ""
End Sub
'***********************************************************
Function LogOpen()
Dim Ws,iReturn,strError
Set ws = CreateObject("WScript.Shell")
On Error Resume Next
iReturn = Ws.Run(File,1,False)
If Err.Number <> 0 Then
strError = "<center><b><font color=Red>The file "& File &" dosen't exists !</font></b></center>"
myDiv.InnerHTML = strError
Exit Function
End If
End Function
'***********************************************************
Sub Submitarea()
Dim oFile,sTxtarea,Readfile,ReadAllTextFile,strError
If Not fso.FileExists(File) Then
Set oFile = fso.OpenTextFile(File,2,true)
oFIle.write "The File "& File &" is created at " & FormatDateTime(now,vbLongTime)
oFile.Close
End If
Set Readfile = fso.OpenTextFile(File,1)
ReadAllTextFile = Readfile.ReadAll
Set oFile = fso.OpenTextFile(File,2,true)
sTxtarea = document.all("Txtarea").Value
oFIle.Writeline
oFIle.write ("Name ")
oFIle.write FormatDateTime(now, 2)
oFIle.write (" ")
oFIle.write FormatDateTime(now,vbLongTime)
'FormatDateTime(now, 4)
oFIle.write (" - ")
oFIle.Write sTxtarea & vbCrLf
oFIle.WriteLine ReadAllTextFile
myDiv.InnerHTML = "Your text has been added to "& File &""
oFile.Close
Call LoadMyFile()
End Sub
'***********************************************************
</script>
<body text="white">
<center><input type="button" name="Log" id="Start" value=" Load LogFile " onclick="LoadMyFile()"><br><br>
<textarea id="txtBody" rows="15" cols="120"></textarea><br><br>
<input type="button" name="Log" id="Start" value=" Open LogFile with Notepad " onclick="LogOpen()">
<input type="button" value=" Clear " onclick="Clear()"></center>
<Div id="myDiv"></Div>
<br><br>
<TEXTAREA style="
Height:193;
Width:100%;
font-Size:12;
color:#000000;
background-color:#ffffe7;
font-weight:normal;
font-family:MS Sans Serif"
TITLE=""
ID="Txtarea" NAME="Txtarea" TABORDER="2" WRAP="PHYSICAL">The contents of this text area will be written to TextArea.txt when you click submit.</TEXTAREA><br><br>
<center><input type="button" value="Submit" onclick="Submitarea">
<input type="reset" value="Reset"></center>
</body>
</html>

VBA HTML Coding , Trying To copy Table

I'm trying to pull Table Data from a website after VBA has already opened and clicked Run on the website. But now having trouble trying to copy all the data over to a sheet. I've tried several different codes to try this posted below. Any help would be great.
Here is the code that I have so far .
Sub AHT()
Application.ScreenUpdating = False
Application.ScreenUpdating = True
Set appIE = CreateObject("InternetExplorer.Application")
sURL = "http://cctools/reporting/main.php?p=centeraht"
' Instructes the macro to open IE and navigate to sURL.
With appIE
.Navigate sURL
.Visible = True
Application.Wait Now + TimeValue("00:00:02")
Set HTMLDOC = .Document
End With
Application.Wait Now + TimeValue("00:00:02")
For Each Btninput In appIE.Document.getElementsByTagName("INPUT")
If Btninput.Value = "Run" Then
Btninput.Click
Exit For
End If
Next
End Sub
I have Tried difference Variations of
Set TDelements = appIE.Docuemnt.getElementsByTagName("TD").innerText
Sheet1.Cells.ClearContents
r = 0
For Each TDelement In TDelements
'Look for required TD elements - this check is specific to VBA Express forum - modify as required
If TDelement.className = "<>" Then
Sheet13.Range("A1").Offset(r, 0).Value = TDelement.innerText
r = r + 1
End If
Next
And this :
Sub Extract_TD_text()
Dim URL As String
Dim IE As InternetExplorer
Dim HTMLDOC As HTMLDocument
Dim TDelements As IHTMLElementCollection
Dim TDelement As HTMLTableCell
Dim r As Long
'Saved from www vbaexpress com/forum/forumdisplay.php?f=17
URL = "http://cctools/reporting/main.php?p=centeraht"
Set IE = New InternetExplorer
With IE
.Navigate URL
.Visible = True
'Wait for page to load
While .Busy Or .ReadyState <> READYSTATE_COMPLETE: DoEvents: Wend
Set HTMLDOC = .Document
End With
Application.Wait Now + TimeValue("00:00:02")
For Each Btninput In IE.Document.getElementsByTagName("INPUT")
If Btninput.Value = "Run" Then
Btninput.Click
Exit For
End If
Next
Set TDelements = appIE.Docuemnt.getElementsByTagName("TD").innerText
Sheet1.Cells.ClearContents
r = 0
For Each TDelement In TDelements
'Look for required TD elements - this check is specific to VBA Express forum - modify as required
If TDelement.className = "data xsmall" Then
Sheet13.Range("A1").Offset(r, 0).Value = TDelement.innerText
r = r + 1
End If
Next
But All with no luck. Here is the Source Code of the website after the vba code has already clicked RUn and Generated the Table
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Reporting</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" />
<link rel="stylesheet" href="/inc/framework_style.css" type="text/css" />
<link rel="stylesheet" href="/inc/jquery-ui-1.8.16.custom.css" type="text/css" />
<script type="text/javascript" src="/inc/ajax.js"></script>
<script type="text/javascript" src="/inc/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="/inc/jquery-ui-1.8.16.custom.min.js"></script>
<link rel="stylesheet" href="inc/style.css" type="text/css" />
</head>
<body>
<div id="wrapper">
<div id="menu"><span class='menuheader'>Menu</span>:<br />
<a href='main.php?p=main'>Home</a><br />
<a href='main.php?p=lobscorecard'>LOB Scorecard</a><br />
<a href='main.php?p=vdn'>VDN Report</a><br />
<a href='main.php?p=centeraht'>UV T1 Center AHT Interval</a><br />
<a href='main.php?p=centerahtd'>UV T1 Center AHT Daily</a><br />
<a href='main.php?p=centert2aht'>UV T2 Center AHT Interval</a><br />
<a href='main.php?p=centerT2ahtd'>UV T2 Center AHT Daily</a><br />
<br />
</div>
<div id='fakeheader'></div>
<div id="main"> <script type='text/javascript'>
//<![CDATA[
document.title = 'Reporting - U-Verse T1 AHT Interval - Center Split';
$(document).ready(function(){
document.getElementById('subpagetitle').innerHTML='U-Verse T1 AHT Interval - Center Split';
});
//]]>
</script>
<form method='post' action=''><table class='data'><tr><th>Date</th><th>SubLOB</th><th class='t_custom' title='Comma separated list of agent skills' style='cursor:help; display: none;'>Skills</th></tr><tr><td><input type='text' size='8' id='date' name='date' value='2014-07-13' /></td><td><select name='sublob' onchange="if (this.value == 4) { $('.t_custom').show(); } else { $('.t_custom').hide(); }"><option value=''>All</option><option value='1'>IPDSLAM/CSI</option><option value='2'>Non IPDSLAM/CSI</option><option value='3'>New Blue</option><option value='4'>Custom</option></select></td><td class='t_custom' style='display: none;'><input type='text' name='skills' value='' /></td></tr><tr><th class='center' colspan='3'><input type='submit' value='Run' /></th></tr></table></form> <script type='text/javascript'>
//<![CDATA[
$('#date').datepicker({dateFormat: 'yy-mm-dd',minDate:'2010-05-26',maxDate:'2014-07-13',showOn:'button',buttonImageOnly: true, buttonImage: '/img/icon_pickdate.gif'});
//]]>
</script>
Running for 2014-07-12 22:00:00 to 2014-07-13 15:32:49<br/>
Skills Used: 330,325,334,329,331,332,327,328,336,323,361,351,352,353,354,355,357,358,359,356,348,371,375,368,379,347,385,337,338,339,341,343,344,177,176<br/>
<table class='data xsmall'>
<tr><th rowspan='2'>Int</th>
<th colspan='3' class='center'>ACD Calls</th>
<th colspan='3' class='center'>Avg ACD</th>
<th colspan='3' class='center'>Avg ACW</th>
<th colspan='3' class='center'>Avg Hold</th>
<th colspan='3' class='center'>AIHT</th>
<th colspan='3' class='center'>AOHT</th><th rowspan='2' class='center'>Forecast<br/>AHT</th><th colspan='3' class='center'>AIHT+AOHT</th></tr>
<tr><th>SAT</th><th>PHX</th><th>Combined</th><th>SAT</th><th>PHX</th><th>Combined</th>
<th>SAT</th><th>PHX</th><th>Combined</th><th>SAT</th><th>PHX</th><th>Combined</th>
<th>SAT</th><th>PHX</th><th>Combined</th><th>SAT</th><th>PHX</th><th>Combined</th>
<th>SAT</th><th>PHX</th><th>Combined</th></tr><tr><td>0000</td><td>5</td><td>13</td>
<td>18</td><td>7.993</td><td>5.533</td><td>6.217</td><td>1.013</td><td>0.536</td>
<td>0.669</td><td>1.360</td><td>0.460</td><td>0.710</td><td>10.367</td><td>6.529</td>
<td>7.595</td><td>0.000</td><td>0.117</td><td>0.084</td><td>0.000</td><td>10.367</td>
<td>6.646</td><td>7.680</td></tr><tr class='altrow'><td>0530</td><td>0</td><td>0</td>
<td>0</td><td>0.000</td><td>0.000</td><td>0.000</td><td>0.000</td><td>0.000</td>
<td>0.000</td><td>0.000</td><td>0.000</td><td>0.000</td><td>0.000</td><td>0.000</td>
<td>0.000</td><td>0.000</td><td>0.000</td><td>0.000</td><td>0.000</td><td>0.000</td>
<td>0.000</td><td>0.000</td></tr><tr><td>0600</td><td>11</td><td>0</td><td>11</td>
<td>22.050</td><td>0.000</td><td>22.050</td><td>2.126</td><td>0.000</td><td>2.126</td>
<td>0.956</td><td>0.000</td><td>0.956</td><td>25.132</td><td>0.000</td><td>25.132</td>
<td>0.000</td><td>0.000</td><td>0.000</td><td>13.825</td><td>25.132</td><td>0.000</td>
<td>25.132</td></tr><tr class='altrow'><td>0630</td><td>20</td><td>0</td><td>20</td>
<td>21.952</td><td>0.000</td><td>23.863</td><td>3.380</td><td>0.000</td><td>3.380</td>
<td>2.262</td><td>0.000</td><td>2.354</td><td>27.593</td><td>0.000</td><td>29.597</td><td>1.576</td><td>0.000</td><td>1.576</td><td>14.839</td><td>29.169</td><td>0.000</td><td>31.172</td></tr><tr><td>0700</td><td>42</td><td>12</td><td>54</td><td>17.212</td><td>7.740</td><td>15.107</td><td>1.444</td><td>0.368</td><td>1.205</td><td>2.442</td><td>0.826</td><td>2.083</td><td>21.099</td><td>8.935</td><td>18.396</td><td>0.561</td><td>0.171</td><td>0.474</td><td>15.983</td><td>21.660</td><td>9.106</td><td>18.870</td></tr><tr class='altrow'><td>0730</td><td>73</td><td>9</td><td>82</td><td>13.539</td><td>15.046</td><td>13.705</td><td>1.005</td><td>1.272</td><td>1.035</td><td>2.057</td><td>1.059</td><td>1.947</td><td>16.602</td><td>17.378</td><td>16.687</td><td>0.142</td><td>0.681</td><td>0.201</td><td>15.867</td><td>16.743</td><td>18.059</td><td>16.888</td></tr><tr><td>0800</td><td>86</td><td>20</td><td>106</td><td>12.600</td><td>15.325</td><td>13.114</td><td>1.924</td><td>0.767</td><td>1.705</td><td>1.237</td><td>1.394</td><td>1.267</td><td>15.761</td><td>17.486</td><td>16.086</td><td>0.715</td><td>0.014</td><td>0.582</td><td>15.250</td><td>16.475</td><td>17.500</td><td>16.669</td></tr><tr class='altrow'><td>0830</td><td>70</td><td>19</td><td>89</td><td>13.039</td><td>20.487</td><td>14.629</td><td>1.552</td><td>1.546</td><td>1.551</td><td>1.995</td><td>5.735</td><td>2.793</td><td>16.586</td><td>27.768</td><td>18.973</td><td>1.098</td><td>0.107</td><td>0.887</td><td>17.333</td><td>17.685</td><td>27.875</td><td>19.860</td></tr><tr><td>0900</td><td>79</td><td>33</td><td>112</td><td>11.347</td><td>17.452</td><td>13.146</td><td>1.410</td><td>1.835</td><td>1.536</td><td>1.438</td><td>5.544</td><td>2.648</td><td>14.195</td><td>24.831</td><td>17.329</td><td>0.624</td><td>1.274</td><td>0.815</td><td>17.065</td><td>14.819</td><td>26.105</td><td>18.144</td></tr><tr class='altrow'><td>0930</td><td>62</td><td>58</td><td>120</td><td>11.863</td><td>9.514</td><td>10.728</td><td>1.278</td><td>1.530</td><td>1.400</td><td>1.868</td><td>2.609</td><td>2.226</td><td>15.009</td><td>13.654</td><td>14.354</td><td>0.705</td><td>0.721</td><td>0.713</td><td>16.625</td><td>15.714</td><td>14.375</td><td>15.067</td></tr><tr><td>1000</td><td>73</td><td>39</td><td>112</td><td>12.805</td><td>13.308</td><td>12.980</td><td>1.366</td><td>1.086</td><td>1.269</td><td>1.723</td><td>2.753</td><td>2.081</td><td>15.893</td><td>17.147</td><td>16.330</td><td>0.360</td><td>0.753</td><td>0.497</td><td>17.275</td><td>16.253</td><td>17.900</td><td>16.827</td></tr><tr class='altrow'><td>1030</td><td>106</td><td>30</td><td>136</td><td>10.530</td><td>15.892</td><td>11.713</td><td>2.047</td><td>1.909</td><td>2.016</td><td>1.658</td><td>3.136</td><td>1.984</td><td>14.234</td><td>20.937</td><td>15.712</td><td>0.341</td><td>1.141</td><td>0.517</td><td>17.139</td><td>14.574</td><td>22.078</td><td>16.230</td></tr><tr><td>1100</td><td>98</td><td>44</td><td>142</td><td>9.911</td><td>14.486</td><td>11.329</td><td>1.027</td><td>0.799</td><td>0.956</td><td>0.888</td><td>2.059</td><td>1.251</td><td>11.825</td><td>17.344</td><td>13.535</td><td>0.630</td><td>0.203</td><td>0.498</td><td>16.017</td><td>12.455</td><td>17.547</td><td>14.033</td></tr><tr class='altrow'><td>1130</td><td>93</td><td>60</td><td>153</td><td>10.327</td><td>12.664</td><td>11.243</td><td>1.621</td><td>1.053</td><td>1.398</td><td>1.052</td><td>1.229</td><td>1.122</td><td>13.000</td><td>14.946</td><td>13.763</td><td>0.369</td><td>0.268</td><td>0.329</td><td>16.751</td><td>13.369</td><td>15.214</td><td>14.092</td></tr><tr><td>1200</td><td>107</td><td>61</td><td>168</td><td>11.503</td><td>13.919</td><td>12.380</td><td>1.101</td><td>0.948</td><td>1.046</td><td>1.538</td><td>1.524</td><td>1.533</td><td>14.143</td><td>16.391</td><td>14.959</td><td>0.851</td><td>0.526</td><td>0.733</td><td>15.800</td><td>14.994</td><td>16.917</td><td>15.692</td></tr><tr class='altrow'><td>1230</td><td>127</td><td>60</td><td>187</td><td>9.198</td><td>12.893</td><td>10.384</td><td>1.638</td><td>0.870</td><td>1.392</td><td>0.814</td><td>0.971</td><td>0.864</td><td>11.650</td><td>14.734</td><td>12.639</td><td>0.690</td><td>0.506</td><td>0.631</td><td>16.217</td><td>12.340</td><td>15.240</td><td>13.270</td></tr><tr><td>1300</td><td>105</td><td>50</td><td>155</td><td>11.266</td><td>13.160</td><td>11.877</td><td>1.067</td><td>0.825</td><td>0.989</td><td>0.603</td><td>0.668</td><td>0.624</td><td>12.936</td><td>14.653</td><td>13.490</td><td>0.917</td><td>1.330</td><td>1.050</td><td>16.271</td><td>13.853</td><td>15.983</td><td>14.540</td></tr><tr class='altrow'><td>1330</td><td>105</td><td>59</td><td>164</td><td>11.154</td><td>13.355</td><td>11.946</td><td>1.243</td><td>0.844</td><td>1.100</td><td>0.620</td><td>1.049</td><td>0.774</td><td>13.017</td><td>15.248</td><td>13.819</td><td>1.130</td><td>0.923</td><td>1.055</td><td>16.908</td><td>14.147</td><td>16.171</td><td>14.875</td></tr><tr><td>1400</td><td>95</td><td>50</td><td>145</td><td>15.041</td><td>19.103</td><td>16.441</td><td>1.443</td><td>1.386</td><td>1.423</td><td>1.683</td><td>1.796</td><td>1.722</td><td>18.166</td><td>22.285</td><td>19.586</td><td>0.926</td><td>0.472</td><td>0.770</td><td>17.075</td><td>19.093</td><td>22.757</td><td>20.356</td></tr><tr class='altrow'><td>1430</td><td>99</td><td>70</td><td>169</td><td>13.438</td><td>14.066</td><td>13.698</td><td>1.331</td><td>0.935</td><td>1.167</td><td>1.942</td><td>1.553</td><td>1.781</td><td>16.711</td><td>16.553</td><td>16.646</td><td>0.948</td><td>1.363</td><td>1.120</td><td>17.000</td><td>17.659</td><td>17.916</td><td>17.765</td></tr><tr><td>1500</td><td>84</td><td>78</td><td>162</td><td>14.921</td><td>13.699</td><td>14.333</td><td>1.390</td><td>1.162</td><td>1.280</td><td>1.872</td><td>1.295</td><td>1.594</td><td>18.183</td><td>16.156</td><td>17.207</td><td>1.286</td><td>0.859</td><td>1.080</td><td>17.575</td><td>19.469</td><td>17.015</td><td>18.287</td></tr><tr class='altrow'><td>1530</td><td>67</td><td>63</td><td>130</td><td>18.298</td><td>14.476</td><td>16.446</td><td>1.833</td><td>0.850</td><td>1.357</td><td>1.863</td><td>0.979</td><td>1.435</td><td>21.995</td><td>16.306</td><td>19.238</td><td>1.398</td><td>1.207</td><td>1.305</td><td>16.475</td><td>23.392</td><td>17.513</td><td>20.543</td></tr><tr><td>1600</td><td>74</td><td>61</td><td>135</td><td>17.055</td><td>18.697</td><td>17.797</td><td>2.100</td><td>1.473</td><td>1.817</td><td>1.655</td><td>2.616</td><td>2.089</td><td>20.810</td><td>22.786</td><td>21.703</td><td>0.823</td><td>0.807</td><td>0.816</td><td>16.850</td><td>21.634</td><td>23.593</td><td>22.519</td></tr><tr class='altrow'><td>1630</td><td>67</td><td>71</td><td>138</td><td>17.288</td><td>13.447</td><td>15.312</td><td>2.450</td><td>1.115</td><td>1.763</td><td>2.284</td><td>1.648</td><td>1.957</td><td>22.022</td><td>16.211</td><td>19.032</td><td>1.534</td><td>1.423</td><td>1.477</td><td>16.181</td><td>23.556</td><td>17.634</td><td>20.509</td></tr><tr><td>Total</td>
<td>1748</td><td>960</td><td>2708</td><td>12.846</td><td>14.207</td><td>13.329</td>
<td>1.521</td><td>1.108</td><td>1.375</td><td>1.478</td><td>1.821</td><td>1.600</td>
<td>15.846</td><td>17.137</td><td>16.303</td><td>0.799</td><td>0.813</td><td>0.804</td>
<td>16.622</td><td>16.644</td><td>17.950</td><td>17.107</td></tr>
</table><br/>
<a href='csvexport.php'>CSV Export</a><br/></div>
<div id="fakefooter"></div>
</div>
<div id="footer"><p><span class='copyright'>© 2014</span></p></div>
<div id="header"><div class='left'><img src='/img/pace_logo_smaller.gif' alt='Pace Logo' /></div><div class='right'><div style='float: right;'>User: [<a href='index.php?logout=1'>Logout</a>]<br />Access Level: User<br /></div></div><span class='subtitle' style='cursor:pointer;' onclick="document.location='main.php';">Reporting</span><br/><span id='subpagetitle'></span></div>
</body>
</html>
Was able to get the oode to work using the copy and paste it all. And use two more subs to clear out extra items not needed .
Global slogininfo As String
Global appIE As Object ' InternetExplorer.Application
Global sURL As String
Global sLogin As String
Global sNotes As String
Global ID As Object ' MSHTML.IHTMLElement
Global infraction As Object ' MSHTML.IHTMLElement
Global Element As Object ' HTMLButtonElement
Global Btninput As Object ' MSHTML.HTMLInputElement
Global ElementCol As Object ' MSHTML.IHTMLElementCollection
Sub AHT()
Application.ScreenUpdating = False
Application.ScreenUpdating = True
Set appIE = CreateObject("InternetExplorer.Application")
sURL = "http://cctools/reporting/main.php?p=centeraht"
' Instructes the macro to open IE and navigate to sURL.
With appIE
.Navigate sURL
.Visible = True
Application.Wait Now + TimeValue("00:00:02")
Set HTMLDOC = .Document
End With
Application.Wait Now + TimeValue("00:00:02")
For Each Btninput In appIE.Document.getElementsByTagName("INPUT")
If Btninput.Value = "Run" Then
Btninput.Click
Exit For
End If
Next
Application.Wait Now + TimeValue("00:00:2")
appIE.ExecWB OLECMDID_SELECTALL, OLECMDEXECOPT_DODEFAULT
appIE.ExecWB OLECMDID_COPY, OLECMDEXECOPT_DODEFAULT
appIE.Quit
Range("A1").Select
ActiveSheet.Paste
Call Cleanup
Call DeleteObj
End Sub
Sub Cleanup()
'
' Cleanup Macro
'
'
Rows("1:15").Select
Range("A15").Activate
Selection.Delete Shift:=xlUp
ActiveWindow.SmallScroll Down:=-24
End Sub
Sub DeleteObj()
Dim obj As Object
For Each obj In ActiveSheet.Shapes
obj.Delete
Next
End Sub
Now with another site I had issues with the copy and paste method wasn't working. But the site has a CSV option to download the date i altered the code to capture that and paste it as such.
Sub Metrics()
Application.ScreenUpdating = False
Application.ScreenUpdating = True
Set appIE = CreateObject("InternetExplorer.Application")
sURL = "http://cctools/rportal/main.php?p=agentavaya"
' Instructes the macro to open IE and navigate to sURL.
With appIE
.Navigate sURL
.Visible = True
Application.Wait Now + TimeValue("00:00:02")
Set HTMLDOC = .Document
End With
Application.Wait Now + TimeValue("00:00:02")
For Each Btninput In appIE.Document.getElementsByTagName("INPUT")
If Btninput.Value = " Run " Then
Btninput.Click
Exit For
End If
Next
Application.Wait Now + TimeValue("00:00:04")
Call CSV
End Sub
Sub CSV()
sCSVLink = "http://cctools/rportal/csvexport.php"
sfile = "csvexport.php"
ssheet = "Sheet10"
Set wnd = ActiveWindow
Application.ScreenUpdating = False
Workbooks.Open Filename:=sCSVLink
Windows(sfile).Activate
ActiveSheet.Cells.Copy
wnd.Activate
Range("A1").Select
ActiveSheet.Paste
Application.DisplayAlerts = False
Windows(sfile).Close False
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub