vba - Converting From Early Binding to Late Binding -


update # 2

i changed values of txtbox , submitbtns (0) (and tried (1) well), no changes.

and need note button has different name , updated accordingly here well.

dim tbox string          'name of object textbox have value changed in dim tbtn string          'name of object button pressed     tbox = "masked1"     tbtn = "button"  if not ie nothing     set txtbox = ie.document.getelementsbyclassname(tbox)(0)     set submitbtn = ie.document.getelementsbyclassname(tbtn)(0)      txtbox.value = tval     submitbtn.click end if 

update # 1

so, things promising suggestion provided @cyboashu. however, still cannot txtbox update value = tval (string).

dim oshell      object dim owin        object dim ie          object dim ltotlwin    long dim lctr  debug.print time & " --- ie objects & values ---"       ' debugger section set oshell = createobject("shell.application")     debug.print time & " [obj ] oshell..: " & oshell    ' debug oshell set owin = oshell.windows()     debug.print time & " [obj ] owin....: " & owin      ' debug owin  ltotlwin = owin.count - 1   '/ starts 0 debug.print time & " [long] ltotlwin: " & ltotlwin      ' debug ltotlwin  lctr = 0 ltotlwin     if ucase(owin.item(lctr).fullname) "*iexplore.exe"         set ie = owin.item(lctr)     end if next debug.print time & " [obj ] ie......: " & ie if not ie nothing     msgbox "found , hooked!!" end if  dim tbox string          'in event textbox's name changes reason     tbox = "masked1"  if not ie nothing     set txtbox = ie.document.getelementsbyclassname(tbox)     debug.print time & " [obj ] txtbox..: " & txtbox     set submitbtn = ie.document.getelementsbyclassname(tbox)     debug.print time & " [obj ] submitbtn:" & submitbtn      txtbox.value = tval     submitbtn.click end if  set shellwins = nothing  debug.print time & "- - - end sub - - -" & e 

end sub

(debugger values if cares)..

2:44:11 pm --- ie objects & values --- 2:44:11 pm [long] ltotlwin: 5 2:44:11 pm [obj ] ie......: internet explorer 2:44:11 pm - - - end sub - - - 

get object won't work here.

what ms says : https://support.microsoft.com/en-gb/kb/239470

calling getobject running activex object on client system large security risk because running object on system accessed without direct user permission, , therefore not allowed internet explorer. there no way change behavior, either through code or manually end user.

try :

sub testielatebinding()      dim oshell              object     dim owin                object     dim ie                  object     dim ltotlwin            long     dim lctr       set oshell = createobject("shell.application")     set owin = oshell.windows()      ltotlwin = owin.count - 1 '/ starts 0      lctr = 0 ltotlwin         if ucase(owin.item(lctr).fullname) "*iexplore.exe"             set ie = owin.item(lctr)         end if     next       if not ie nothing         msgbox "found , hooked!!"     end if   end sub 

Comments