Issue
- Press Windows+R in order to open Run Dialog Box.
- Type ms-settings: into Run Dialog Box.
- Press OK in order to open Windows Settings Screen.
Do you know any VBA code which gives me same result like above actions?
I mean I just want to open Windows Settings screen via VBA code.
Please note that I am a Windows 10 user.
Solution
- Use API
ShellExecute
to execute scriptStart-Process ms-settings:
Option Explicit
#If VBA7 Then
Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" ( _
ByVal hwnd As LongPtr, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As LongPtr
#Else
Declare Function ShellExecute 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
#End If
Sub OpenSystemSettings()
ShellExecute 0, "open", "ms-settings:", vbNullString, vbNullString, vbNormalFocus
End Sub
Answered By - taller Answer Checked By - Clifford M. (WPSolving Volunteer)