Automating Internet Explorer via VBA for Windows 11 - vba

I realise there are other threads for this but I coudnt see a complete answer for my circumstances after searching a few hours, just lots of "will try this or this"
I have a significant number of web scrapers written using VBA to run IE, which I share with various non-computer literate co-workers. What is the simplest way to get them working on Windows 11 assuming Selenium is not an option (too difficult to set up and install for my end users) and converting to python isn't possible due to the amount of re-writing.
Is there a simple way to re-write the codes, or some way to reintroduce IE? Short example below
Set IE = New InternetExplorer
IE.navigate ("https://example.com/login")
IE.Visible = True
Call IEWait
Sub IEWait()
cTime = Now + TimeValue("00:01:00")
Do Until (IE.ReadyState = 4 And Not IE.Busy)
If Now < cTime Then
DoEvents
Else
IE.navigate ("htpps://example.com/logout")
IE.Quit
Set IE = Nothing
MsgBox "Error"
Exit Sub
End If
Loop
End Sub

I would like to inform you that on Windows 11 OS, you will not get Internet Explorer browser but the MSHTML (Trident) engine(underlying platform for Internet Explorer 11) will be there on Windows 11 OS and continue to be supported (in other words, unaffected by this announcement).
As part of the IE 11 application retirement, certain COM automation
scenarios were inadvertently broken. These IE COM objects have been
restored to their original functionality as of the Windows 11 November
2021 "C" update and the Windows 10 February 2022 "B" update (for
versions 1809 and later). The COM scenarios will also continue to work
after the IE11 desktop application is disabled after June 15, 2022.
Based on the above information, your VBA IE automation code will continue to work on Windows 11 OS. You do not need to configure any special settings for that, just make sure that Windows 11 OS has latest updates installed on it. You could try to run the code in a similar way as you are running on other Windows OS(e.g. Windows 10). When you run your VBA IE automation code on Windows 11 OS , it will also launch the same UI interface as Internet Explorer browser.
Reference: Internet Explorer 11 desktop app retirement FAQ
Let me know if you are facing an issue while running your VBA code on Windows 11 OS. I will try to provide suggestions to fix it.

Related

How can I program the speakerphone on a pocketpc running Windows Mobile 6.5?

Thanks to Josef who put me onto the right track for coding Windows Mobile 6.5 phone support.
I have found some more tricks which I would like to share. Yes, I know it is old technology, but there are many devices being sold that still run mobile 6.5. So: How can I program the speakerphone on a pocketpc running Windows Mobile 6.5 in .NET Compact Framework 3.5 in VB.NET?
This is very simple once you know how. You call the DLL file ossvcs, but this DLL file exports functions by ordinal numbers, not by names.
See http://msdn.developer-works.com/article/12376405/Reject+Call for more details. The code follows:
<DllImport("ossvcs.dll", EntryPoint:="#218")> _
Private Shared Sub setSpeaker(ByVal sValue As Integer)
End Sub
' Call setSpeaker(1) to turn on and setSpeaker(0) to turn off.
' If you set the speaker on when you create the line than it will always turn the speaker on for every call made

Full shell (explorer.exe) running for a RemoteApp on Terminal server

Folks,
I'll been fighting this for a few weeks now. We have a proprietary corporate app running on thin clients in our organization. From this app we can apply VBA scripting behind the scenes to do simple functions. In the past adding buttons to open IE and direct them to certain web sites to enter data, open Calc and etc.
Recently I have been working the code below. It was developed on the Server using a RDP session which launches the full desktop and explorer.exe. What I have noticed that if explorer.exe isn't running then the code bombs at line in the function that reads "For Each oWin In oShApp.Windows " with "Run-time error '429'".
However if I script to start explorer.exe (which is bad because it enables the Start-bar and Task-bar) on the ThinClient which launches the desktop and full capabilities and it runs just fine as the Thin Client users that are logged in.
I have read a little bit about the "Limited Shell" that runs when using a remoteapp and not the full desktop and was wondering if there was anyway around it, without enable the start-menu and taskbar?
See the code below.
Thanks for the help, CreteIT
Private Sub cmdHomePage_Click()
Dim ie As Object
Dim sMatch As String
sMatch = "http://www.companyweb.com"
On Error Resume Next
Set ie = GetIEatURL(sMatch & "*")
On Error GoTo 0
If Not ie Is Nothing Then
ShowWindow ie.hwnd, 9
BringWindowToTop ie.hwnd
Else
Dim strHome
Dim strAPP
strHome = "c:\progra~1\intern~1\iexplore.exe www.companyweb.com"
strAPP = Shell(strHome, vbNormalFocus)
End If
End Sub
Function GetIEatURL(sMatch As String) As Object
Dim ie As Object, oShApp As Object, oWin As Object
Set oShApp = CreateObject("Shell.Application")
For Each oWin In oShApp.Windows
If TypeName(oWin.Document) = "HTMLDocument" Then
Set ie = oWin
If LCase(ie.LocationURL) Like LCase(sMatch) Then
Set GetIEatURL = ie
Exit For
End If
End If
Next
Set oShApp = Nothing
Set oWin = Nothing
End Function
I work on the RemoteApp team at Microsoft. I'm not quite clear whether you're running this script from an actual RemoteApp session or your own setup that has a different shell that replaces explorer.exe (or perhaps no shell at all), but either way the answer is about the same.
The Shell.Application ActiveX object your script is trying to instantiate appears to be implemented by the shell - typically explorer.exe. If that isn't running, the COM runtime won't be able to create an instance of the object, and when you try to activate it you'll get an error.
The obvious solution is to run explorer.exe but, as you observed, that also includes the taskbar and start menu, which you might not want. RemoteApp runs its own shell replacement (rdpshell.exe), but that doesn't implement Shell.Application, so just running your application under RemoteApp won't fix the problem.
There are a few potential solutions I can think of:
If you're not using RemoteApp, you could write your own replacement shell that does implement Shell.Application. This is quite a lot of work and there might not be a lot of documentation around on how to do it properly. If you already have a replacement shell, you might be able to extend it to implement Shell.Application.
You could use a different method to enumerate windows. Unfortunately this probably means Win32 (via the EnumWindows function), which isn't directly accessible from VB scripts; you might have to create an ActiveX object that implements the behavior you want, and invoke it from the script.
Similar to option 2 but more heavyweight - you could make that ActiveX object implement the whole Shell.Application interface - even though it isn't actually the shell - and register it on the remote machine. I can't guarantee you won't run into problems if you do this though; it isn't something I've tried before.
None of these solutions are ideal, unfortunately, but hopefully something lets you do what you need to.

MS Access crashes when trying to close down a connection to Blackbaud's Raiser's Edge API

I am the IT department of a Non-Profit organization. I have a question today which might be too specialized for this forum and I hope I do not waste my time writing it up. We are using Blackbaud's 'Raiser's Edge' (RE) Software (written in VB6 and VB.net as far as I know) to keep track of our membership and donations. We have an MS Access application (have been using it since before we got RE) to process donations and for now I want to keep it and only do minor changes to adapt it to the new software.
The MS Access program is now doing a few calls to the RE API which work great. To login and establish a connection I have to create a new 'REAPI' object and use it for other API calls. That REAPI object has a method called: SignOutOnTerminate which needs to be set to TRUE when creating that object. It is supposed to kill all connections to RE once my application closes. There is no regular .close method.
Once I create the object I can do work as many times as I want and there is no problem at all as far as I can see.
However when trying to close the application or set the object to nothing (Set REAPI = Nothing) Access crashes immediately (It fades out and I get the message that Windows is looking for a solution to the problem. Then Access closes and restarts itself.)
It is more annoying and unprofessional then hindering production but I want to fix it.
The App was developed on Windows 7 64-bit with Access 2010 32-bit. It was tested on Windows XP with Office 2003 or 2007 machines (32-bit) and behaves the same way.
I have posted this problem already on 2 Blackbaud forums and tried a suggested a work around which did not work (kill the process with a shell command and then set the object to nothing). Hopefully I will get more answers soon.
I tried to just exclude the SignOutOnTerminate when creating the object. But got the same behavior.
I looked in the Event Manager --> Application Log and found the Crash. It reported that access crashed because of this dll: C:\Windows\System32\MSVBVM60.dll (It is actually located in the SysWos64 folder as it is a 32-bit application).
Looking up this error I found some suggestions to replace it with an earlier version of the dll, the one which ships with XP. I found a file and tried the suggestion but it still crashed. The error log reported the older version number as faulting so I registered it correctly.
I also created a case with Blackbaud but the rep did not know what the problem is and did not have MS Access installed. He is trying to get his support team to install it for him so he can test and investigate this error.
The last suspicion I have is that the API is causing the error and my code is fine.
But before I make this assumption and until I get my answer from Blackbaud I want to do a final check, but I have run out of ideas for further trouble shooting and resorted to pose this problem in this forum.
Any Ideas?
I realise that this is an old thread and if you have solved this by now then that is great. However this is a known issue with The Raiser's Edge API. If you use .NET with RE's API (which is COM based) there is definitely some resource that is not cleaned up properly. At one point I suspected that it was something to with making use of RE's graphical interface i.e. by calling the regular login method to log you into RE. However even if you log in to RE using the "as a server" method supplying the user name and password it still crashes on exiting the application.
We have an installer that sets up credentials in RE. The installer is in .NET and accesses the RE API. We now show a message just before the end of the application telling users to ignore the impending crash... Not a great solution by any means.

Determine scanner architecture, flatbad or feeder, WIA

I am trying to write a function (in VBA) that will scan a single page if the scanner has a flatbad architecture, or multiple if it has a feeder. I am using Windows Image Acquisition 2.0 on Windows XP. The following line of code reutrns an error:
MsgBox wiaScanner.Properties("3086").Value
In here you can see that property 3086 stands for Document Handling Capabilities. When I run it I get "ID not found". This worked fine on windows 7. I'm sure there's an alternative way for windows XP, I just couldn't find it.
Any ideas?
Thanks

Watin: Launching IE with createInNewProcess==true times out IE and doesn't start test

I'm trying to develop and run 2 test projects (which use the same web application) at a time . When I run 2 different tests with 2 NUNIT-GUI instances a problem occures, because IE shares sessions and 1 test affects the other (logs out the user from the application). I found that Watin can create seperate processes of IE, constructor:
IE Constructor (String, Boolean)
Parameters:
url The URL te open
createInNewProcess if set to true the IE instance is created in a new process.
But when I set the createInNewProcess to true and launch a test just a blank IE window opens, no site address in entered and NUNIT times out with a communicate:
WatiN.Core.Exceptions.IENotFoundException
: Could not find an IE window matching
constraint: Timeout while waiting to
attach to newly created instance of
IE.. Search expired after '30'
seconds.
What could be the problem? At the moment as a workaround I've started to virtualize a second system.
Watin uses your IE installed in the system, so even if you create newer instances they all shall share the same session which is due to the default behavior of Internet Explorer. You cant run multiple logins with Watin in parallel.
Also, WatiN.Core.Exceptions.IENotFoundException comes occasionally when a previous IE instance opened by Watin remains unclosed. Watin tries to search that in next run and throws this exception.
Make sure you go to task manager and close all instances of IE and then start your tests.
Also may mean that you are running this from a service. I kept getting this error message when running from a service but not when running from command line.