I have an Access 2016 application that opens Notepad++ with the Shell function when the user clicks on a text box with a path in it. The Shell function then opens Notepadd++ and opens the document found in the path. That works fine. However, Notepad++ with the opened document is in a window behind the Access application window. I have not been able to find a way to bring it in front of the Access app window. I've searched many times and the answer I've come up with is what I'm using. It activates the window it seems but does not bring it to the foreground. Here is the code that is in the On Click event of the text box that holds the file path:
Private Sub FindPath_Click()
Dim dbPath As String
dbPath = Me.TextBoxPath ' TextBoxPath is the name of the text box with the path in it
Notepad = Shell("C:\Program Files\NotepadPlus\Notepad++.exe " & Chr(34) & dbPath & Chr(34), vbMaximizedFocus)
AppActivate Notepad
End Sub
Note: the Chr(34) is to put quotes around the path to handle spaces in the file name.
The value in the textbox would be something like: D:\FolderA\FolderB\This is my document.txt
Does anyone know how to bring the Window with Notepad++ opened in it to the foreground in front of the Access app?
Thank you much!
Private Sub FindPath_Click()
Dim dbPath As String
dbPath = Me.TextBoxPath ' TextBoxPath is the name of the text box with the path in it
Notepad = Shell("C:\Program Files\NotepadPlus\Notepad++.exe " & Chr(34) & dbPath & Chr(34), vbMaximizedFocus)
AppActivate Notepad
End Sub
Note: the Chr(34) is to put quotes around the path to handle spaces in the file name.
The value in the textbox would be something like: D:\FolderA\FolderB\This is my document.txt
Does anyone know how to bring the Window with Notepad++ opened in it to the foreground in front of the Access app?
Thank you much!