Does anyone know the code for opening a specific notepad file from a button? I know there's a default button but it only opens a blank notepad page. I need to open some written instructions from a button you see.
With Notepad, since it falls under the Windows System directory, all you have to do is:
Code:
Shell "notepad.exe " & FilePath
However, if you want to use Wordpad, which is installed under a different directory, the following will not work:
Code:
Shell "wordpad.exe " & FilePath
The following function will open wordpad with a specified file:
Code:
Public Function OpenWordpadFile( _
ByVal PathName As String, _
Optional WindowStyle As VBA.VbAppWinStyle = vbMinimizedFocus) As Double
Dim WshShell As Object
Set WshShell = CreateObject("WScript.Shell")
OpenWordpadFile = WshShell.Run(WshShell.RegRead( _
"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\WORDPAD.EXE\") _
& " """ _
& PathName _
& """", WindowStyle, False)
Set WshShell = Nothing
End Function