2016-01-05 185 views

回答

3

你不知道。通過MsgBox顯示的對話框使用爲系統對話框配置的字體。如果您需要自定義對話框,您需要創建一個自定義對話框,例如like this

Sub CustomMsgBox(msg) 
    Set ie = CreateObject("InternetExplorer.Application") 
    ie.Navigate "about:blank" 

    While ie.ReadyState <> 4 : WScript.Sleep 100 : Wend 

    ie.ToolBar = False 
    ie.StatusBar = False 
    ie.Width  = 300 
    ie.Height = 120 

    ie.document.body.innerHTML = "<p class='msg'>" & msg & "</p>" & _ 
    "<p class='ctrl'><input type='hidden' id='OK' name='OK' value='0'>" & _ 
    "<input type='submit' value='OK' id='OKButton' " &_ 
    "onclick='document.all.OK.value=1'></p>" 

    Set style = ie.document.CreateStyleSheet 
    style.AddRule "p.msg", "font-family:times new roman;font-weight:bold;" 
    style.AddRule "p.ctrl", "text-align:rightf;" 

    ie.Visible = True 

    On Error Resume Next 
    Do While ie.Document.all.OK.value = 0 
    WScript.Sleep 200 
    Loop 
    ie.Quit 
End Sub 
0

我想補充預/預標籤,如下圖所示,這樣的格式不丟失。然後我會將高度/寬度更改爲標準的最小屏幕尺寸,例如800x400。然後,視障人士將StatusBar更改爲True,以啓用「更改縮放級別」。

Sub CustomMsgBox(msg) 
    Set ie = CreateObject("InternetExplorer.Application") 
    ie.Navigate "about:blank" 

    While ie.ReadyState <> 4 : WScript.Sleep 100 : Wend 

    ie.ToolBar = False 
    ie.StatusBar = True 
    ie.Width  = 800 
    ie.Height = 400 

    ie.document.body.innerHTML = "<p class='msg'><pre>" & msg & "</pre></p>" & _ 
    "<p class='ctrl'><input type='hidden' id='OK' name='OK' value='0'>" & _ 
    "<input type='submit' value='OK' id='OKButton' " &_ 
    "onclick='document.all.OK.value=1'></p>" 

    Set style = ie.document.CreateStyleSheet 
    style.AddRule "p.msg", "font-family:times new roman;font-weight:bold;" 
    style.AddRule "p.ctrl", "text-align:rightf;" 

    ie.Visible = True 

    On Error Resume Next 
    Do While ie.Document.all.OK.value = 0 
    WScript.Sleep 200 
    Loop 
    ie.Quit 
End Sub 
+1

這看起來像一個評論加入到另一個答案,而不是一個實際的答案本身。 –

+0

同意。這是一個小小的改變。 – vbcoder