VBA Code Falling Down

Mike H

Active Member
Joined
Feb 15, 2006
Messages
321
Morning everyone!!

I have inherited the following code and its started failing on the line thats highlighted by stars below in the code...

Can anyone tell why by any chance, or what that line is attempting to do??...???



Code:
Global IE
Global CS






Sub LOGIN()

Dim X As String

X = Sheets("Back Sheet").Range("L20")
Calculate
If X = "X" Then
MsgBox "ERROR time must be at least 10 mins in the future"
Exit Sub
Else
End If



number = Sheets("Back Sheet").Range("L20")
listname = Sheets("Front Sheet").Range("B20")
Filename = Sheets("Front Sheet").Range("B19")
  
  Set IE = CreateObject("InternetExplorer.Application")
  IE.Navigate "https://62.232.19.24/MEnable/Client/servlets/Login?b=2057"
IE.Visible = True
IE.Top = 0
IE.Left = 0
IE.Height = 0
IE.Width = 0



Call WS


  IE.Document.all("ClientOnly").Value = "Funding Corporation"
  IE.Document.all("AccountOnly").Value = "Sbaldwin"
  IE.Document.all("Password").Value = "Skyline12"

CS = "Logging into Server"
Call stat


Call WS
PRE = IE.locationURL
  SendKeys "{tab}{tab}{tab}{tab}{tab}{tab}{enter}", 1

CS = "Login Sucessful"
Call stat
Call WS
While PRE = IE.locationURL
Call WS
Wend
PRE = IE.locationURL

  IE.Navigate IE.Document.links(3).href

Call WS
While PRE = IE.locationURL
Call WS
Wend
PRE = IE.locationURL

IE.Navigate IE.Document.links(11).href

Call WS
While PRE = IE.locationURL
Call WS
Wend
PRE = IE.locationURL

CS = "Creating List Name"
Call stat
SendKeys "{tab}"
IE.Document.all("Name").Value = listname
IE.Document.all("Name").Select
SendKeys "{tab}{enter}"


Call WS
While PRE = IE.locationURL
Call WS
Wend
PRE = IE.locationURL
CS = "List Created"
Call stat

IE.Navigate IE.Document.links(3).href
Call WS
While PRE = IE.locationURL
Call WS
Wend
PRE = IE.locationURL

IE.Navigate IE.Document.links(15).href
Call WS
While PRE = IE.locationURL
Call WS
Wend
PRE = IE.locationURL

Sheets("Back Sheet").Range("B24") = IE.Document.Body.OuterHtml

CS = "Importing Texting List"
Call stat

IE.Document.all("ImportToList").Value = Sheets("Back Sheet").Range("C23").Value




IE.Document.all("upload").Select
SendKeys Filename


SendKeys "{tab} {tab} {tab} {tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{enter}"

Call WS
While PRE = IE.locationURL
Call WS
Wend
PRE = IE.locationURL



Sheets("Back Sheet").Range("B24") = IE.Document.Body.innerText

CS = Format(Sheets("Back Sheet").Range("D23"), "0") & " Users Added: " & Format(Sheets("Back Sheet").Range("E23"), "0") & " Users Updated: " & Format(Sheets("Back Sheet").Range("F23"), "0") & " Users Discarded: " & Format(Sheets("Back Sheet").Range("G23"), "0")
hold = CS
Call stat

IE.Navigate IE.Document.links(6).href

Call WS
While PRE = IE.locationURL
Call WS
Wend
PRE = IE.locationURL

IE.Navigate IE.Document.links(11).href

Call WS
While PRE = IE.locationURL
Call WS
Wend
PRE = IE.locationURL

IE.Navigate IE.Document.links(19).href

Call WS
While PRE = IE.locationURL
Call WS
Wend
PRE = IE.locationURL
IE.Document.all("ConfirmOptIn").Checked = True

SendKeys "{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{enter}"

Call WS
While PRE = IE.locationURL
Call WS
Wend
PRE = IE.locationURL

IE.Navigate IE.Document.links(11).href
Call WS
While PRE = IE.locationURL
Call WS
Wend
PRE = IE.locationURL

IE.Document.all("ExistingList").Value = listname


SendKeys "{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{enter}"

Call WS
While PRE = IE.locationURL
Call WS
Wend
PRE = IE.locationURL


CS = "Inputting Send condidtions"
Call stat


IE.Document.all("DateDay").Value = Sheets("Back Sheet").Range("I19")
IE.Document.all("DateMonth").Value = Sheets("Back Sheet").Range("I20")
IE.Document.all("DateYear").Value = Sheets("Back Sheet").Range("I21")
IE.Document.all("DateHour").Value = Sheets("Back Sheet").Range("J18")
IE.Document.all("DateMinute").Value = Sheets("Back Sheet").Range("K18")
IE.Document.all("Text").Value = "{MM}"
IE.Document.all("ServiceLevel").Value = 334
IE.Document.all("Validity").Value = 60

 While IE.busy
  DoEvents
  Wend
  
  
SendKeys "{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{enter}"

Call WS
Sheets("Back Sheet").Range("B24") = IE.Document.Body.innerText
While Sheets("Back Sheet").Range("H23") = "ON"
Sheets("Back Sheet").Range("B24") = IE.Document.Body.innerText
Call WS
Wend



***IE.Document.all("Name").Value = listname********************


PRE = IE.Document.Body.innerText

SendKeys "{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{enter}"

While PRE = IE.Document.Body.innerText
Call WS
Wend

Sheets("Back Sheet").Range("B24") = IE.Document.Body.innerText

CS = Sheets("Back Sheet").Range("I23")
Call stat
IE.Visible = False
Set IE = Nothing
Windows("MobileMarketer Front End PR.xls").Activate

MsgBox "Send Summary:" & vbCrLf & vbCrLf & hold & vbCrLf & vbCrLf & CS & vbCrLf & vbCrLf & "Programmed Issue Point " & Sheets("Back Sheet").Range("I18") & " at " & Sheets("Back Sheet").Range("L18")

Sheets("Front Sheet").Range("B22") = "Idle"
Windows("MobileMarketer Front End PR.xls").Activate
If CS = "Error In Final import stage" Then
MsgBox "There has been an error in importing the list." & vbCrLf & "If necissary repeat the import cycle from the start" _
& vbCrLf & "There are a number of possible reasons:" _
& vbCrLf & "1. You have already sent a batch on the current import (so re Import the list, conditions can remain the same" _
& vbCrLf & "2. You have attempted to send the texts while using other programs on your desk top, (Retry but Don't touch the computer" _
& vbCrLf & "3. Any internet connectivity problems will affect this service so if the internet is slow keep trying or try later"
Else
End If


EX:
Exit Sub

errorback:
MsgBox "There has been an error in importing the list." & vbCrLf & "If necissary repeat the import cycle from the start" _
& vbCrLf & "There are a number of possible reasons:" _
& vbCrLf & "1. You have already sent a batch on the current import (so re Import the list, conditions can remain the same" _
& vbCrLf & "2. You have attempted to send the texts while using other programs on your desk top, (Retry but Don't touch the computer" _
& vbCrLf & "3. Any internet connectivity problems will affect this service so if the internet is slow keep trying or try later"

IE.Visible = False
Set IE = Nothing
Resume EX:

 End Sub

Cheers

Mikey
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Mike

What it appears this code is trying to do is automate IE and extract data from a web page.

It's using SendKeys which is notoriously flaky, but that might not be the root of the problem.

The problem line is this you say?
Code:
IE.Document.all("Name").Value = listname
This appears to be trying to put a value into an element called Name on the webpage.

I don't have time at the moment to test the code but I'll check back later.:)
 
Upvote 0
Thats a great start thanks Norie...

At least i know what the line is trying to do...?? Problem is i'm not sure where the line relates back to in the code to get to the root of whats going on here!!

Thanks SO SO much for your help so far!!
 
Upvote 0
Mike

What the code is doing is automating Internet Explorer, taking data from a worksheet, putting into a webpage and then getting data from that webpage.

Throughout the code there are calls to other subs like this.
Code:
Call WS
I'm afraid I can't help much further than that as I can't access the webpage since it's a secure site.

I would suggest that since you've 'inherited' this code you try and find out what it's purpose actually is.
 
Upvote 0
Hello..

Sub WS looks like this..

Code:
Sub WS()
    While IE.busy
    DoEvents
      While IE.busy
      DoEvents
    Wend
   Wend
  While IE.busy
  DoEvents
  Wend
  
  
End Sub

What is the possible reason that peice of code has stopped working?? Anything in particular?
 
Upvote 0
Mike

I'm sorry but I really can't help much further - this code is for accessing a secure (work? intranet? ) web site.

Like I said you should try and find out the intended purpose of the code.

Just because you've 'inherited' it doesn't mean you need to use it.:)
 
Upvote 0

Forum statistics

Threads
1,215,263
Messages
6,123,954
Members
449,135
Latest member
jcschafer209

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top