رمز VBA لإدخال البيانات إلى صفحة ويب أو IE

enter data to webpage
جدول المحتويات

VBA Enter Data into webpage – IE Automation using VBA GetElementByID function

ماذا فعلا:

If you are trying to do ie automation or trying to enter data to webpage using VBA then this post if for you. We will show the step by step instructions on how to enter/fill data in ie using VBA.

Enter Data To WebpagePin

لماذا فعلا:

This is very helpful when you want to enter or fill multiple fields in a webpage regularly. Or if you want to login to website in a single click without using the browser’s default Remember My Password option etc.

كيف to enter data to webpage using vba




In this example we are using Excel VBA for IE Automation however you can use any VBA supported platform.

الخطوة 1: Open the Excel workbook and got to VBA code builder (Alt + F11) and Open a New Module.

Enter Data To Webpage

الخطوة 2: Copy and Paste the below code in it.

فرعي خاص wpieautologin()

خافت ie مثل SHDocVw.InternetExplorer

Set ie = جديد SHDocVw.InternetExplorer

ie.Visible = حقيقي 

ie.Navigate “https://www.askeygeek.com/wp-admin” ‘we are trying to login to askeygeek.com admin page

Do

DoEvents

Loop Until ie.readystate = 4

‘ie READYSTATE has 5 different status codes, here we are using status 4:

‘Uninitialized = 0

‘Loading = 1

‘Loaded = 2

‘Interactive =3

‘Complete = 4 

Call ie.Document.GetElementByID(“user_login”).SetAttribute(“value”, “testUser”)

Call ie.Document.GetElementByID(“user_pass”).SetAttribute(“value”, “testPass12345”)

 ‘to find the “<input……/>” tag hyper link and to click the button

Set AllInputs = ie.Document.getelementsbytagname(“input”) ‘you can use any tagname as you wish

    ل Each hyper_link في AllInputs

        لو hyper_link.Name = “wp-submit” Then ‘you can use .name, .id etc

            hyper_link.Click

            Exit ل

        End لو

    التالي

Do

DoEvents

Loop Until ie.readystate = 3

Do

DoEvents

Loop Until ie.readystate = 4

End الفرعية

الخطوه 3: Click the Run button or F5.(Also you can insert a button/shape in excel sheet then right click and assign this macro to run every time.)

Enter Data To Webpage

Notes 1: Make sure ‘Microsoft Internet Controls’ is enabled from the Tools – References.

Ie AutomationPin

Notes 2: Right click the webpage to and click View source to find the GetElement values

GetelementsbytagPin



Picture of Anson Antony
أنسون أنتوني
أنسون هو مؤلف مساهم ومؤسس في www.askeygeek.com. لقد كان تعلم أي شيء جديد هو شغفه دائمًا، ASKEYGEEK.com هو نتيجة شغفه بالتكنولوجيا والأعمال. لقد حصل على عقد من الخبرة المتنوعة في الاستعانة بمصادر خارجية للعمليات التجارية، والمالية والمحاسبة، وتكنولوجيا المعلومات، والتميز التشغيلي وذكاء الأعمال. خلال فترة عمله، عمل في مؤسسات مثل Genpact وHewlett Packard وM*Modal وCapgemini في أدوار ومسؤوليات مختلفة. بعيدًا عن الأعمال والتكنولوجيا، فهو من عشاق الأفلام ويقضي ساعات معًا في مشاهدة وتعلم السينما وصانع أفلام أيضًا!

7 Responses

اترك تعليقاً

لن يتم نشر عنوان بريدك الإلكتروني. الحقول الإلزامية مشار إليها بـ *

تهانينا!
لقد فعلتها،
لا تغلق!

الوصول إلى UberCreate Creator Pro
مجانا!!!

هذه النافذة المنبثقة لن تظهر متروك لكم مرة أخرى!!!

4
Share to...