VBA的预测文本不起作用

VBA的预测文本不起作用

本文介绍了VBA的预测文本不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,这可能是一个非常愚蠢的问题,但是我的预言性文字偶尔会出现.我目前正在使用Excel 2016. 

Okay this might be a very stupid question but my predictive text when writing only happens occasionally. I'm currently using Excel 2016. 

键入 Range(会打开工具提示:
 
但是,在 With Sheets(SName)中键入 .Range()不会打开工具提示:

Typing Range( opens the tooltip:
 
But, typing .Range( in With Sheets(SName) does not open the tooltip:

有人可以帮忙吗?非常感谢你!

Can anybody help? Thank you very much!

推荐答案

Excel无法计算出对象类型 Sheets(SName)是什么,因此 IntelliSense 无法提供提示.

Excel can't work out what Object Type Sheets(SName) is, so IntelliSense can't provide tips.

这是意料之中的,因为 Sheets 集合包含 Worksheet Chart 对象.这意味着它不知道 Range 集合的参数应该是-甚至它集合.(考虑 .Add 方法-每种对象类型都有不同的参数!)

This is to be expected, since the Sheets collection contains both Worksheet and Chart Objects. This means that it doesn't know what the Arguments for the Range collection should be - or even that it is a collection. (Think about the .Add method - different arguments for every object type!)

但是,一项快速测试表明,如果您使用 Worksheets(SName),它 still 仍无法识别对象类型-即使中的所有对象工作表集合是工作表对象.

However, a quick test shows that it still can't identify the Object type if you use Worksheets(SName) - even though all objects in the Worksheets collection are Worksheet objects.

以下代码确实允许Excel识别对象类型,从而允许IntelliSense显示:

The following code does allow Excel to identify the Object type, and thus allows IntelliSense to display:

Option Explicit 'Always put this at the top of your Module!

Sub DataRoll()
    Dim wsTMP As Worksheet, SName As String

    SName = "Testing"

    Set wsTMP = ThisWorkbook.Worksheets(SName)

    With wsTMP
        .Range 'IntelliSense will pop up as soon as you add "("
    End With

    Set wsTMP = Nothing 'Tidy up after ourselves
End Sub

这篇关于VBA的预测文本不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 05:38