我使用以下VBA打开消息框:
Sub Message()
MsgBox ("Do you want create a file on your desktop?" _
& vbCr & " " _
& vbCr & "Once you click yes an unprotected file with all sheets visible will be saved on your desktop and opened. You can immediately start working with this file.")
End Sub
所有这些都很好。
但是,如您在屏幕快照中所见,“文件”一词位于另一行。是否可以格式化messagebox
或更改VBA
代码,以使“文件”一词不会出现在不同的行中?
答案 0 :(得分:3)
这取决于用户PC的分辨率。就我而言,我什至是这样的:
如果要控制行,则应编写一个自定义表单。在那里,您将可以更好地控制显示,并且如果您对其显示属性有所了解,则可以精确模拟MsgBox()
:
一些示例代码Label1
是一个标签元素:
Private Sub UserForm_Initialize()
Me.Label1 = "Do you want create a file on your desktop?" _
& vbCr & " " _
& vbCr & "Once you click yes an unprotected file with all sheets visible will be saved on your desktop and opened." & _
vbCrLf & "You can immediately start working with this file."
End Sub
答案 1 :(得分:1)
也许可以使用换行符来调整代码以适合您的情况。例如:
Sub Message()
MsgBox ("Do you want create a file on your desktop?" _
& vbCr & " " _
& vbCr & "Once you click yes an unprotected file" _
& vbCr & " " _
& vbCr & "with all sheets visible will be saved on your desktop and opened." _
& vbCr & " " _
& vbCr & "You can immediately start working with this file.")
End Sub