Results 1 to 2 of 2
  1. #1
    MTD072 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Sep 2017
    Posts
    14

    Extracting a vaule from IE web Application via Access VBA

    Hail! Experts. I seek thy counsel.



    Trying to extract a value from a SAP web application and send a value to a SAP web application (more worried about the first part) from VBA

    There are a lot of public declares and functions from other parts of the code that aren't particularly relevant. I've removed the ones that stuck out at me but there may be some extras still there.

    Now. My problem...

    It doesn't seem to like to getElementbyID and throws me an object required error but I can't see where I haven't got an object specified.

    Any assistance or advice from someone with experience in meshing VBA with web apps would be greatly appreciated.

    Code as follows

    Code:
    Option Compare Database
    Public crn As String
    Public objIEBrowser As Object
    Public cfsession As Object
    Public Declare PtrSafe Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
    Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As LongPtr) 'For 64 Bit Systems
    Public Declare PtrSafe Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
    Declare Function apiShowWindow Lib "user32" Alias "ShowWindow" _
                (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    Global Const SW_MAXIMIZE = 3
    Global Const SW_SHOWNORMAL = 1
    Global Const SW_SHOWMINIMIZED = 2
    Public Const HWND_TOP = 0
    Public Const CF_TEXT = 1
    Declare PtrSafe Function FindWindow Lib "user32" _
        Alias "FindWindowA" ( _
        ByVal lpClassName As String, _
        ByVal lpWindowName As String) As LongPtr
        
    Declare PtrSafe Function SetWindowPos Lib "user32" ( _
        ByVal hwnd As LongPtr, _
        ByVal hWndInsertAfter As LongPtr, _
        ByVal x As Long, _
        ByVal y As Long, _
        ByVal cx As Long, _
        ByVal cy As Long, _
        ByVal wFlags As Long) As Long
     
    Function FnLaunchIEBrowser()
    Set objIEBrowser = CreateObject("InternetExplorer.Application")
    objIEBrowser.Left = 0
    objIEBrowser.Visible = True
    objIEBrowser.Navigate2 "***obfuscated***"
        Do While objIEBrowser.Busy
        Loop
    hwnd = FindWindow(vbNullString, "Home Page - [Interaction Center ]")
    hwnd = SetWindowPos(hwnd, HWND_TOP, 100, 100, 0, 0, SWP_NOSIZE)
    apiShowWindow objIEBrowser.hwnd, SW_MAXIMIZE
    End Function
    
    Sub allocatecase()
    Dim SWs As SHDocVw.ShellWindows, vIE As SHDocVw.InternetExplorer
    Dim Count As Integer
    Dim NewURL, pcrn As String
    Dim doc, element
    Dim reading As Object
    Dim HWNDSrc As Long
    Set SWs = New SHDocVw.ShellWindows
    For Each vIE In SWs
        If vIE.LocationURL = “” Then
        Else
        NewURL = vIE.LocationURL
            If Mid(NewURL, 8, 7) = "sap-c4p" Then GoTo sessfound
        End If
    Next
    MsgBox "APP session has failed to auto-initialise. Please manually launch a session and maximise it on your left monitor."
    GoTo ender
    sessfound:
    Set cfsession = vIE
    Set SWs = Nothing
    Set vIE = Nothing
    HWNDSrc = cfsession.hwnd
    SetForegroundWindow HWNDSrc
    Set reading = cfsession.Document.getelementbyid("INPUT_CRN")
    pcrn = reading.Value
    ender:

  2. #2
    Perceptus's Avatar
    Perceptus is offline Expert
    Windows 10 Access 2016
    Join Date
    Nov 2012
    Location
    Knoxville, Tennessee
    Posts
    659
    I dont see where cfsession is declared as more than just an object, are you declaring it as an ms xml object or similar? Maybe MS DOM object would do you better

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 02-27-2016, 10:59 AM
  2. Replies: 1
    Last Post: 08-27-2015, 06:05 AM
  3. Replies: 4
    Last Post: 01-05-2014, 02:09 PM
  4. Replies: 6
    Last Post: 07-13-2011, 02:47 PM
  5. Access application to Web based application
    By admaldo in forum Access
    Replies: 0
    Last Post: 06-12-2008, 06:22 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums