Hi,
I have a code in a module that with open a password protected sharefolder which will prompt a popup.
Windows Security
Enter Network Credentials
The code work fine.
This will not put the login prompt in focus at the Access application view. If I use vbNormalFocus, it will show both the Login prompt and Explorer window.
Is there a better way to hide the Explorer window and only show the Login prompt in Focus?
I have tried searching but there were only codes to hide Explorer window. None of the code could put the login prompt in Focus. I couldn't find any code that will put the Login prompt in focus.
Sample of the code below, it doesn't put the login prompt on focus.
I have a code in a module that with open a password protected sharefolder which will prompt a popup.
Windows Security
Enter Network Credentials
The code work fine.
Code:
'connect to password protected sharefolder
Shell "C:\WINDOWS\explorer.exe """ & strPath & "", vbHide
This will not put the login prompt in focus at the Access application view. If I use vbNormalFocus, it will show both the Login prompt and Explorer window.
Is there a better way to hide the Explorer window and only show the Login prompt in Focus?
I have tried searching but there were only codes to hide Explorer window. None of the code could put the login prompt in Focus. I couldn't find any code that will put the Login prompt in focus.
Sample of the code below, it doesn't put the login prompt on focus.
Code:
Sub fRunTest()
Dim PID As Long
Dim Ret As String, strUNC As String, WinWnd As Long
strUNC = "\\MyComputer\MyShareFolder\"
PID = Shell("c:\windows\explorer.exe """ & strUNC & "", vbNormalFocus)
If PID = 0 Then MsgBox "Error starting the app"
'retrieve the handle of the window
mWnd = InstanceToWnd(PID)
'Set the exe parent
SetParent mWnd, hWndAccessApp
'Put the focus on exe
Putfocus mWnd
ShowWindow mWnd, SW_HIDE 'hide explorer
End Sub
Function InstanceToWnd(ByVal target_pid As Long) As Long
Dim test_hwnd As Long, test_pid As Long, test_thread_id As Long
'Find the first window
'test_hwnd = FindWindow(ByVal 0&, ByVal 0&)
test_hwnd = FindWindowAny("Credential Dialog Xaml Host", "Windows Security")
Do While test_hwnd <> 0
'Check if the window isn't a child
If GetParent(test_hwnd) = 0 Then
'Get the window's thread
test_thread_id = GetWindowThreadProcessId(test_hwnd, test_pid)
If test_pid = target_pid Then
InstanceToWnd = test_hwnd
Exit Do
End If
End If
'retrieve the next window
test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT)
Loop
End Function