How to modify vba code to input data instead of extracting data from an element ID?

I have the below code that I use to extract data, but I need to modify it to input data into the same element ID.

Sub GetTicketData()

    Dim objIE As SHDocVw.InternetExplorer
    Dim objShell As SHDocVw.ShellWindows
    Dim objIEDoc As MSHTML.HTMLDocument
    Dim objFound As MSHTML.HTMLBaseElement
    Dim strURL As String
    Dim blnFoundWebSite As Boolean
    Dim objDialog As FileDialog
    Dim objFSO As Scripting.FileSystemObject
    Dim objText As Scripting.TextStream
    Dim objDebugFile As Scripting.TextStream
    
    Dim varFrame As Variant
    Dim varFrame2 As Variant
    Dim objFrameDoc As MSHTML.HTMLDocument
    Dim objFrameDoc2 As MSHTML.HTMLDocument
    Dim i As Integer
    Dim j As Integer
    
    Dim objElem As MSHTML.HTMLBaseElement
    Dim objElemDoc As MSHTML.HTMLDocument
    Dim objElem2 As MSHTML.HTMLBaseElement
    Dim objElemDoc2 As MSHTML.HTMLDocument

        
    Set objShell = New SHDocVw.ShellWindows
    Set objFSO = New Scripting.FileSystemObject
    
    ' **** Set the Web Address Here ****
    strURL = "https://servman/sm/index.do"
    
    
    
    ' Look for the appropriate open IE Window
    For Each objIE In objShell
        If TypeOf objIE.document Is MSHTML.HTMLDocument Then
            Set objIEDoc = objIE.document
            If Not (objIEDoc Is Nothing) Then
                If objIEDoc.url = strURL Then
                    blnFoundWebSite = True
                    Exit For
                End If
            End If
        End If
    Next
    
    Set objFrameDoc2 = objIEDoc

    If blnFoundWebSite Then
        ' Make sure IE is done loading the page
        Do Until Not objIE.Busy
            DoEvents
        Loop
        
        ' Make Sure we had some frames returned
        If objIEDoc.frames.Length > 0 Then
            ' Get the Document from the 1st Frame
            Set varFrame = objIEDoc.frames.Item(0)
            Set objFrameDoc = varFrame.document
            
            ' Get the Detail Frame (Sub Frame #2)
            If objFrameDoc.frames.Length > 1 Then
                Set varFrame2 = objFrameDoc.frames.Item(1)
                Set objFrameDoc2 = varFrame2.document
                
                'Title
                Set objFound = objFrameDoc2.getElementById("X95")
                If objFound Is Nothing Then
                    Range("K5").Value = ""
                Else
                    Range("K5").Value = objFound.Value
                End If
                
                
            Else
               
                'Title
                Set objFound = objFrameDoc.getElementById("X95")
                If objFound Is Nothing Then
                    Range("K5").Value = ""
                Else
                    Range("K5").Value = objFound.Value
                End If
                
                                
            End If ' objFrameDoc.frames.Length > 1
        End If ' objIEDoc.frames.Length > 0
        
        
        
    End If
    
    
    Set objIE = Nothing
    Set objShell = Nothing
    Set objIEDoc = Nothing
    Set objIEDoc = Nothing
    Set objFound = Nothing
    Set objDialog = Nothing
    Set objFSO = Nothing
    Set objText = Nothing
    Set objDebugFile = Nothing
End Sub

Open in new window

kbay808Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Robberbaron (robr)Commented:
confirm you are trying to  'write data' to the web report ?
0
kbay808Author Commented:
I'm not sure about the term web report.  I think of it as a web form.  I attached a screen shot of the website with a red box around the box with the target data that I want to replace.
0
kbay808Author Commented:
0
Robberbaron (robr)Commented:
i dont think you can do what you ask...

I believe you can write to the element, but it wont update.  Unless you save as a new 'local' HTML document and then reopen that.

               'Title
                Set objFound = objFrameDoc.getElementById("X95")
                If objFound Is Nothing Then
                    'cant write to it
                Else
                     objFound.Value = "MY new DATA"
                End If

Open in new window


what you are trying to do is commonly done by javascript on the web page itself.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kbay808Author Commented:
It worked!!!  Thank you very much
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.