0

I am trying to get my code to enter text into a new text box in a new frame after a button is pressed. I thought it would be as simple as assigning the value to the text box as the cell contents, but I'm getting:

Run-time error 91 "Object variable or With block variable not set".

Am I missing a Dim and Set pair or something? Or does it have something to do with identifying the new frame?

Sub FillInternetForm()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.navigate "https://omcoasys.com/sites/DynamicsAx/Project/Enterprise%20Portal/ProjProjectsListPage.aspx?WCMP=PPTB&redirected=1&WMI=EPProjTableList"
IE.Visible = True

While IE.busy
DoEvents
Wend



IE.Document.All("Dynamics.Ax.ActionPane.InitiateProjects.NewGroup.EPProjectWizard-Large").Click
Application.Wait (Now + TimeValue("0:00:02"))
IE.Document.All("ctl00_m_g_d387d089_b21a_4261_b434_b0ecfe6b3378_ctl01_wizProjTableWizard_txtProjGroup").Value = ThisWorkbook.Sheets("sheet1").Range("a1")
End Sub
Mathieu Guindon
  • 69,817
  • 8
  • 107
  • 235
Sean
  • 71
  • 2
  • 8
  • Which line is throwing the error? See [error handling](http://stackoverflow.com/documentation/vba/3211/error-handling#t=201703290226514025652) and [runtime error 91](http://stackoverflow.com/documentation/vba/8917/vba-run-time-errors/27750/run-time-error-91-object-variable-or-with-block-variable-not-set#t=201703290227221830917) on Documentation.SO. You're assuming an object reference exists, but the reference is `Nothing` and you can't call instance members without an object reference. – Mathieu Guindon Mar 29 '17 at 02:28
  • Thanks for the reply. The program runs fine without the last line above End Sub – Sean Mar 29 '17 at 03:31
  • Is 2 seconds wait enough? Try add the wait block `While IE.busy : DoEvents : Wend` to replace the Wait? Then is that **ct100...** element available? Will it change? – PatricK Mar 29 '17 at 03:40
  • [UPD4 there](http://stackoverflow.com/a/23232573/2165759) may help (change `WScript.Sleep 10` to `DoEvents`). – omegastripes Mar 29 '17 at 12:14
  • Thank you guys for all your help. I never did get it figured out and went a different route. There may have just been an issue referencing the text box, I'm not sure. – Sean Mar 29 '17 at 23:43

0 Answers0