0

I am working on a script on VBA to capture some repetitive data on a CRM web database but I am having a problem with an input field that has a required attribute and when the script enters the data and i save the values entered the element with the Required attribute does not get saved in the form and it clears the field.

Is there a way to prevent this?

i tried several methods but nothing is working, here is a sample of the way I am trying to enter the values on the input fields.

sub CRMdata()
    Dim ie As New SHDocVw.InternetExplorerMedium
    Dim htmldoc As MSHTML.HTMLDocument
    Dim htmlcol As MSHTML.IHTMLElementCollection
    Dim htmlbody As MSHTML.IHTMLElement
    Dim htmlobj As MSHTML.IHTMLElement
    Dim iframe As HTMLIFrame
    Dim frame As HTMLFrameElement
    Dim descrip1 As String

    descrip1 = "name1"

    'load webpage and store IE Document
    With ie
        .Visible = True
        .navigate ("my webapge")
    End With
    Do While ie.readyState <> READYSTATE_COMPLETE
        Application.StatusBar = "Loading WebPage..."
        DoEvents
    Loop
    Application.Wait (Now + TimeValue("00:00:03"))
    Set htmldoc = ie.document

    'set iframe work area in CRM Environment
    Set iframe = htmldoc.getElementById("CRMApplicationFrame")
    Set htmldoc = iframe.contentWindow.document

    'set frame work area 1 in CRM enviroment
    Set frame = htmldoc.getElementById("WorkAreaFrame1")
    Set htmldoc = frame.contentWindow.document

    With htmldoc
        .getElementById("C14_W65_V67_V70_V71_btadminh_struct.description").Value = descrip1
    End With

    'Save the CRM opportunity
    'htmldoc.getElementById("C14_W65_V67_thtmlb_button_1").Click

End Sub
luis_g881
  • 1
  • 1
  • IE should no longer be used. It is being actively phased out by MS. So first check if the page still works manually in IE. Then you can use your solution transitionally. But the recommendation is to use another technique like SeleniumBasic to automate Chrome or Edge. About your problem: Without the URL I can only guess. I assume that you have to trigger one or more events. Have a look at this older answer of mine. There you can see what I mean and how it works. https://stackoverflow.com/questions/63294113/automate-ie-via-excel-to-fill-in-a-dropdown-and-continue/63299608#63299608 – Zwenn Jan 04 '23 at 10:30

0 Answers0