473,811 Members | 2,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to fill a text field in internet explorer using VBA?

20 New Member
I have a VBA program that automates an internet explorer process the whole code works except one piece.

when I try using this code,

Expand|Select|Wrap|Line Numbers
  1. Dim IEapp As Object
  2.   Dim IEdoc As Object
  3. Set IEapp = New InternetExplorer
  4. IEdoc.all("ctl00$ContentPlaceHolder1$uxQuantity").Value = 4
I recieve an error that says "Run-time error '91': Object variable or With block variable not set"

I think there is something I'm not seeing with the site source because I use a similar code for a different website and it works.

I have attached the site source to this email and if someone can look at it and let me know whay am I missing I would highly appreciate it.

Thanks
Attached Files
File Type: txt site source.txt (25.8 KB, 907 views)
Feb 2 '11 #1
14 13672
Rabbit
12,516 Recognized Expert Moderator MVP
You never assign the IEDoc variable. Right now it's nothing.
Feb 2 '11 #2
loudey
20 New Member
thanks for your reply, oh sorry I missed up while copying the code

Expand|Select|Wrap|Line Numbers
  1. Dim IEapp As Object 
  2. Dim IEdoc As Object 
  3. Set IEapp = New InternetExplorer
  4. Set IEdoc = IEapp.document
  5. IEdoc.all("ctl00$ContentPlaceHolder1$uxQuantity").Value = 4
  6.  
I still have the same issue though, even with the IEDoc variable assigned
thanks
Feb 3 '11 #3
Rabbit
12,516 Recognized Expert Moderator MVP
You've instantiated an internet explorer object but it's not actually on a page. It's either on a blank page or on whatever the homepage is at. If it's at the homepage, then it's likely the page hasn't finished loading.
Feb 3 '11 #4
loudey
20 New Member
thanks for the reply and sorry I sent you a private message even though you had already replied but for some odd reason when I checked this post earlier it didn't show your reply.

anyway I have been trying to avoid bothering you with the whole code so I have been just copying the part with the problem but that seemed that it have caused more problem than helped. so here is the full code.

Expand|Select|Wrap|Line Numbers
  1. Sub FixQtyMisMatch()
  2.  
  3. Sheets("Sheet1").Select
  4.  
  5.  
  6.  
  7.   Dim IEapp As Object
  8.   Dim IEdoc As Object
  9.   Dim SearchText As String
  10.   Dim URL As String
  11.   Dim ElementCol As MSHTML.IHTMLElementCollection
  12.   Dim Link As MSHTML.HTMLAnchorElement
  13.   Dim i As Integer
  14.   Dim EnterKey As String
  15.     Set IEapp = New InternetExplorer
  16.  
  17.  
  18. i = 3
  19.  
  20.  
  21.     'Define Quote Number
  22.     QuoteNo = Cells(i, 29).Value
  23.  
  24.  
  25.     ' Launch Internet Explorer and go to the site
  26.     URL = "https://ccp.abb.com/Ccp/SearchTender.aspx"
  27.  
  28.  
  29.  
  30.       With IEapp
  31.         .Visible = True
  32.         .navigate URL
  33.       End With
  34.             ' Wait till the page is loaded
  35.                  While IEapp.Busy
  36.                      DoEvents
  37.                  Wend
  38.             ' Time delay for 5 seconds
  39.             Dim dclock As Double
  40.             dclock = Timer
  41.              While Timer < dclock + 5
  42.                  DoEvents
  43.              Wend
  44.  
  45.  
  46.  
  47.     ' Inserts item number
  48.         Set IEdoc = IEapp.document
  49.         IEdoc.all("ctl00$ContentPlaceHolderMain$uxId").Value = QuoteNo
  50.  
  51.  
  52.      ' Clicks the search button
  53.        IEdoc.all("ctl00$ContentPlaceHolderMain$uxSearchButton").Click
  54.           ' Wait till the page is loaded
  55.                  While IEapp.Busy
  56.                      DoEvents
  57.                  Wend
  58.  
  59.    ' Clicks item link on search page
  60.     Set ElementCol = IEapp.document.getElementsByTagName("a")
  61.  
  62.     For Each Link In ElementCol
  63.      If Link.innerHTML = QuoteNo Then
  64.             Link.Click
  65.          Exit For
  66.         End If
  67.     Next Link
  68.             ' Wait till the page is loaded
  69.                  While IEapp.Busy
  70.                      DoEvents
  71.                  Wend
  72.  
  73.                ' Clicks item link on search page
  74.     Set ElementCol = IEapp.document.getElementsByTagName("a")
  75.  
  76.     For Each Link In ElementCol
  77.      If Link.innerHTML = Cells(i, 27).Value Then
  78.             Link.Click
  79.          Exit For
  80.         End If
  81.     Next Link
  82.             ' Wait till the page is loaded
  83.                  While IEapp.Busy
  84.                      DoEvents
  85.                  Wend
  86.  
  87.             ' Insert Correct Quantity
  88.     'EnterKey = "{enter}"
  89.     IEdoc.all("ctl00$ContentPlaceHolder1$uxQuantity").Value = 4
  90.     'IEdoc.all("ctl00_ContentPlaceHolder1_uxQuantity").Select
  91.     'SendKeys EnterKey, True
  92.  
  93.                 ' Time delay for 1 seconds
  94.             dclock = Timer
  95.              While Timer < dclock + 1
  96.                  DoEvents
  97.              Wend
  98.  
  99.         ' Clicks the Save FTC button
  100.      ' IEdoc.all("ctl00$ContentPlaceHolderMain$uxFtc$uxSaveFtc").Click
  101.            'Wait till the page is loaded
  102.                 While IEapp.Busy
  103.                      DoEvents
  104.                Wend
  105.  
  106.  
  107.  
  108.      End Sub
  109.  
  110.  
Feb 4 '11 #5
Rabbit
12,516 Recognized Expert Moderator MVP
Can you post the source HTML of that page?
Feb 4 '11 #6
loudey
20 New Member
Sorry didn't have access to my work computer over the weekend. Anyway please find the source HTML attached. let me know if you can't open it. (Couldn't attach HTML so i had to zip the file)
Attached Files
File Type: zip Source.zip (5.2 KB, 284 views)
Feb 7 '11 #7
Rabbit
12,516 Recognized Expert Moderator MVP
I don't see a control with the identified as ctl00$ContentPl aceHolder1$uxQu antity in the source.
Feb 7 '11 #8
loudey
20 New Member
I don't think you can see the whole webpage in the HTML file, however if you click (CTRL-F) in the "site source.txt" and paste "ctl00$ContentP laceHolder1$uxQ uantity" you will find that under "Input Name" and that is where I want to fill in the text box. I have also included a jpeg of what the site looks like if this helps any.
Attached Images
File Type: jpg website.jpg (78.6 KB, 603 views)
Feb 7 '11 #9
Rabbit
12,516 Recognized Expert Moderator MVP
Is it in a frame? Because you'll need to use
Expand|Select|Wrap|Line Numbers
  1. IEdoc.all("frameID").all("elementID")
Feb 7 '11 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1375
by: Ronen | last post by:
Hi, Does anyone experienced memory leak in Iexplore.exe when use treeview (MS IE Controls? I'm have tested this with a simple web page with a few tree nodes generated on the server. Then I added a setTimeout that postback the page every 2 seconds, I checked the VM size of the IExplorer.exe and found out that it constantly increases
2
6626
by: Ofer Lavi | last post by:
Hi, I am trying to build an activeX that, if missing, will be downloaded and setup automatically on the client's browser (internet explorer). Using VB6, it was easy, using the <Object> tag, the classid attribute for its reference, and the codebase attribute for its .cab file. Now, I am using vb.net. I managed to create the object (using ComClass<...> and ClassId, InterfaceId and EventsId.
2
5551
by: v.srikhar | last post by:
hi I had some problem .Ii had to open the ms word file in IE itself not outside using jsp or java can any one solve it out. thanks
1
5202
by: Andy Chen | last post by:
Some web sites offer contents in multiple languanges, we can do it manully by click on IE Options - Internet options. My questions is how to change it by C# code. Thanks! Andy
11
11629
by: Wendy | last post by:
Hello, I have a program that does the following: When a user clicks on a row in a VB.NET datagrid, it will open a web page in Internet Explorer (that corresponds to that item in the selected row in the datagrid). It will automatically print that web page, and then it will close the Internet Explorer window. I have code that works perfectly when a regular web page is opened, however when a pdf web page is opened the printing never...
0
941
by: pigeonrandle | last post by:
Hi, Has anyone tackled this before? I understand i might need to use the DOM, but cant work out how to get the handle of a 'child window' from it :(. The instance of Internet Explorer Server is running in a process other than my own just to make it more difficult! Any ideas?! James
0
1011
by: jaggu | last post by:
HI All, I was making a demo were in i will set the uri path for the internet explorer using setURI function....along with this i also want to set the user name and password for the webpage contents ...like if my web page is http://www.mail.yahoo.com... then i want to fill the user name and password through my code itself and sign in automatically.... How can i achieve this.....
0
4514
by: gaurav2325 | last post by:
Hi, I would like to create a plugin for internet explorer to run my document. My document contains specific type of data, so that, I want whenever the user open that document (that is word document with special data embeded) my plugin gets the id of that embeded object and open with the specific application of MS office. Pls help me out creating that plugin. I tried MSHTML (but dont have complete idea whether will it help or not) ...
0
1672
by: nehacredo | last post by:
hi alll.. i wanna display a word file content in a browser..how can i do that..i hav done one coding in that i can display the contents...but with contents some symbols also coming... anyone pls help me my code... <%@ page import="java.io.*,javax.servlet.http.HttpServletRequest,javax.servlet.ServletInputStream" %> <%@ page import="java.io.FileWriter,java.io.IOException" %> <html> <head> <title>
0
10648
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10389
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10135
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9205
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6890
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4339
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3867
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3018
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.