我想通过VBA代码打开Windows设置屏幕

问题描述 投票:0回答:1
  1. Windows+R 以打开 运行 对话框。
  2. 运行对话框中输入ms-settings:
  3. OK 以打开 Windows 设置 屏幕。

你知道任何 VBA 代码可以给我与上述操作相同的结果吗?

我的意思是我只想通过 VBA 代码打开 Windows 设置 屏幕。

请注意,我是 Windows 10 用户。

以下链接可能会有所帮助。

https://www.digitalcitizen.life/introducing-windows-10-ways-open-settings/

vba windows shell command settings
1个回答
0
投票
  • 使用API
    ShellExecute
    执行脚本
    Start-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
© www.soinside.com 2019 - 2024. All rights reserved.