X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
   Reply to this topicStart new topic
> A System Shutdown Has Already Been Scheduled Error, Access 2013    
post Feb 14 2018, 05:17 PM

Posts: 192
Joined: 1-November 08
From: New York Area, USA

I'm getting the topic title error message when the user is doing the following:

There are forms in the Access programs containing hyperlinks. If the user clicks on the hyperlink code runs and opens Internet Explorer and navigates to the link. If the user closes Internet Explorer and clicks on another hyperlink the error message comes up.

I did some research and one of the options was to do a reboot of the computer. That didn't work.

Another thing to try was to catch the error and resume the code. When I catch the error and resume the next line of code it won't work because an instance of Internet Explorer hasn't been created.

This is the code:
'Find out if IE is already opened
Set objShell = CreateObject("Shell.Application")
Set objAllWindows = objShell.Windows

For Each ow In objAllWindows
If (InStr(1, ow, "Internet Explorer", vbTextCompare)) Then
'Debug.Print ow

b = True
Exit For

End If

'Start Internet Explorer if it's not already open
If Not b Then
Set IE = CreateObject("internetexplorer.application")
IE.navigate strLink

'3/1/17 - Maximize
apiShowWindow IE.Hwnd, 3

'3/1/17 - Set focus
SetForegroundWindow IE.Hwnd

Loop Until IE.ReadyState = 4

IE.Visible = True

'Set to open Internet Explorer
Set IE = ow
IE.navigate strLink

'3/1/17 - Maximize
apiShowWindow IE.Hwnd, 3

'3/1/17 - Set focus
SetForegroundWindow IE.Hwnd

'ow.Visible = True
IE.Visible = True
End If

The code crashes on this line when creating an instance of Internet Explorer: Set IE = CreateObject("internetexplorer.application")

Also this code has been working for over a year. Any ideas what I can try to solve this issue?
Go to the top of the page
post Feb 19 2018, 07:48 AM

Posts: 91
Joined: 25-March 10
From: St Albans, UK

I've been using this alternative approach for some time now without any issues - it's not my solution - full credit to Dev Ashish.

Instead of clicking URLs, I have logos to sites that, when clicked, trigger a simple command: fHandleFile {URL}, {Window Format}

Very clean and efficient - and can also be used to access files on pcs, networks, etc.

Paste the following to a new module, and then call it from your forms as needed. It uses your default Browser, and opens new browser instances if needed, or reuses existing automatically.

'************ Code Start **********
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
' Code Courtesy of
' Dev Ashish
Private Declare Function apiShellExecute Lib "shell32.dll" _
    Alias "ShellExecuteA" _
    (ByVal hwnd As Long, _
    ByVal lpOperation As String, _
    ByVal lpFile As String, _
    ByVal lpParameters As String, _
    ByVal lpDirectory As String, _
    ByVal nShowCmd As Long) _
    As Long

'***App Window Constants***
Public Const WIN_NORMAL = 1         'Open Normal
Public Const WIN_MAX = 3            'Open Maximized
Public Const WIN_MIN = 2            'Open Minimized

'***Error Codes***
Private Const ERROR_SUCCESS = 32&
Private Const ERROR_NO_ASSOC = 31&
Private Const ERROR_OUT_OF_MEM = 0&
Private Const ERROR_FILE_NOT_FOUND = 2&
Private Const ERROR_PATH_NOT_FOUND = 3&
Private Const ERROR_BAD_FORMAT = 11&

'***************Usage Examples***********************
'Open a folder:     ?fHandleFile("C:\TEMP\",WIN_NORMAL)
'Call Email app:    ?fHandleFile("mailto:dash10@hotmail.com",WIN_NORMAL)
'Open URL:          ?fHandleFile("http://home.att.net/~dashish", WIN_NORMAL)
'Handle Unknown extensions (call Open With Dialog):
'                   ?fHandleFile("C:\TEMP\TestThis",Win_Normal)
'Start Access instance:
'                   ?fHandleFile("I:\mdbs\CodeNStuff.mdb", Win_NORMAL)

Function fHandleFile(stFile As String, lShowHow As Long)
Dim lRet As Long, varTaskID As Variant
Dim stRet As String
    'First try ShellExecute
    lRet = apiShellExecute(hWndAccessApp, vbNullString, _
            stFile, vbNullString, vbNullString, lShowHow)

    If lRet > ERROR_SUCCESS Then
        stRet = vbNullString
        lRet = -1
        Select Case lRet
            Case ERROR_NO_ASSOC:
                'Try the OpenWith dialog
                varTaskID = Shell("rundll32.exe shell32.dll,OpenAs_RunDLL " _
                        & stFile, WIN_NORMAL)
                lRet = (varTaskID <> 0)
            Case ERROR_OUT_OF_MEM:
                stRet = "Error: Out of Memory/Resources. Couldn't Execute!"
            Case ERROR_FILE_NOT_FOUND:
                stRet = "Error: File not found.  Couldn't Execute!"
            Case ERROR_PATH_NOT_FOUND:
                stRet = "Error: Path not found. Couldn't Execute!"
            Case ERROR_BAD_FORMAT:
                stRet = "Error:  Bad File Format. Couldn't Execute!"
            Case Else:
        End Select
    End If
    fHandleFile = lRet & _
                IIf(stRet = "", vbNullString, ", " & stRet)
End Function
Go to the top of the page
post Feb 19 2018, 04:51 PM

Posts: 192
Joined: 1-November 08
From: New York Area, USA

Hi Chris,

Thanks for posting that code. I'll take a look at it.

What I ended up doing was finding and modifying some code that would check if any instances were open for IE and if there were, to close them. That worked.

It seems that when the code opens up IE and goes to the link it would create two instances that would show up in the task manager. I could use Quit because that would close IE and the user wanted IE to stay open so that they could look at the link. So I put the new code when the hyperlink field was clicked.

Thanks again.
Go to the top of the page

Custom Search

RSSSearch   Top   Lo-Fi    23rd March 2019 - 07:42 PM