VBA error excel to website submission

vinniehnk

New Member
Joined
Apr 11, 2012
Messages
7
Hello all,

What I am trying to do is to take several parts of data from an excel sheet and move them to a ticketing system we use to log tickets. So far i have:

Sub Fill_Form()
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
' im using facebook as an example
.navigate URL:="http://www.facebook.com"
Do Until .readystate = 4
DoEvents
Loop
Set mytextfield1 = .document.all.Item("Email")
mytextfield1.Value = Sheets("test_vba").Range("a1").Value
Set mytextfield1 = .document.all.Item("Pass")
mytextfield1.Value = Sheets("test_vba").Range("a2").Value
End With
End Sub

So far, I have encountered several issues. First, being that I have encountered an Automation error, the object invoked has disconnected from its client

I have looked it up on the web and what I am getting is i need to add an "option explicit" however, i am very basic with code and have no clue what the code would look like after adding that. I cannot figure out the variables aspect of the option explicit

. Also i would need to expand it to allow more data, so if you can give me pointers that way too it would be helpful
 

CharlesChuckieCharles

Well-known Member
Joined
May 10, 2011
Messages
2,153
"Option Explicit"

should be typed into the (General) Declarations part of a VBA Module
It states that all Variables have to be declared before use!

Your routine with declarations

Code:
Sub Fill_Form()
 
Dim IE As Object
Dim MyTextField1 As Object
 
Set IE = CreateObject("InternetExplorer.Application")
    
With IE
    .Visible = True
    ' im using facebook as an example
    .navigate [URL="http://www.mrexcel.com/forum/="http://www.BBC.co.UK/News"]URL:="http://www.BBC.co.UK/News[/URL]"
    Do Until .readystate = 4
        DoEvents
    Loop
    
    Set MyTextField1 = .document.all.Item("Email")
    MyTextField1.Value = Sheets("test_vba").Range("a1").Value
    
    Set MyTextField1 = .document.all.Item("Pass")
    MyTextField1.Value = Sheets("test_vba").Range("a2").Value
End With
IE.Close
Set IE = Nothing
Set MyTextField1 = Nothing
End Sub
 

vinniehnk

New Member
Joined
Apr 11, 2012
Messages
7
Charles, thank you! That makes perfect sense now that i can compare apples to apples. Im still getting the error, so im thinking my IT might have a hand in blocking this. I'll check with them
 

vinniehnk

New Member
Joined
Apr 11, 2012
Messages
7
Ok, Im still stumped. That code works perfect on any site, EXCEPT our local intranet sites. The only variable that I can see is our intranet sites are Protected Mode: Off where external sites are On. Ive worked wth our IT guy who says we cant modify this and that his research indicated an error with Active X controls. Is this a possibility? If so can i possibly add a variable to handle that?

Also, on the off chance I have to use sendkeys, where would you recommend starting? ive spent days on the google search responses and nothing seems to be relevant to my issue?
 

Forum statistics

Threads
1,082,284
Messages
5,364,282
Members
400,787
Latest member
bs04c

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top