提示不会出现在Excel for Mac 15的Application.InputBox中

时间:2017-06-29 18:58:45

标签: excel macos inputbox

这是我的代码:

Sub demo1()
    Dim Rng1 As Range
    Set Rng1 = Application.InputBox("The Prompt", "The Dialog Title", Type:=8)
End Sub

以下是Excel for Windows的结果(我还点击了一个单元格来添加引用):

enter image description here

以下是Excel for Mac的结果(我点击了一个单元格,如上所述):

enter image description here

我正在使用15版。简单地说,我在Excel for Mac上看不到提示Some research表示人们可以使用普通InputBox(而不是Application.InputBox)作为解决方法,但我需要加强版本,因为用户需要点击一个小区范围,并且set变量必须是范围对象。普通的vb InputBox无法做到这一点。提前感谢任何建议。

2 个答案:

答案 0 :(得分:0)

我在这里找到了解决方案的高低,但却无法找到解决方案。似乎Mac对话框根本不包含两个不同的部分(标题+提示)。我已经创建了一个我发布的解决方法,如果有人遇到同样的问题,它可能会有用。但如果有人能提出更好的解决方案,我会说出答案。

首先,我们检查一下我们是否在PC或Mac上使用:

On Error Resume Next
If Val(Application.Version) = Int(Val(Application.Version)) Then
    theOs = 0 'whole version number = PC
Else
    theOs = 1 'version number with decimal = Mac
End If
If Err.Number <> 0 Then
    Err.Clear
    theOs = 0
End If
On Error GoTo 0

如果我们在PC上使用提示,或者如果我们在Mac上使用标题,则使用提示

theQ1 = "This is my prompt"
theQ2 = ""
If theOs = 1 Then
    theQ2 = theQ1
    theQ1 = ""
End If
Set Rng1 = Application.InputBox(theQ1, theQ2, Type:=8)

对于PC,它的工作原理正常...对于Mac,提示符代替标题,因此用户仍然可以理解所请求的内容。一个重要的缺点是标题线在空间上更有限,我们不能使用换行符。

答案 1 :(得分:0)

如果这仍然与您的需求相关,我前段时间遇到了类似的问题,我找到了一个令人满意的解决方案。我在这里概述了它: Why does the prompt text not appear for my InputBox using VBA in Excel for Mac?