Predictive Text for VBA not working [closed]

核能气质少年 提交于 2021-02-08 11:43:19

问题


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

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

Can anybody help? Thank you very much!


回答1:


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

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!)

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.

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



回答2:


Intellisense is auto enabled in VBA, not sure what you mean when you say it happens occasionally ( An example scenario when it would not appear would help us understand better)

However you can try the following steps:

  1. Try Ctrl+Space within the editor (Which brings about a list of available predictions)

  2. Alternatively you can Navigate to the Object Browser (F2) which allows you to explore the class libraries and the available objects

See below screen shot for example ( When you hit Ctrl+Space after Sheets( )




回答3:


I think this is normal behaviour. I'm working with excel vba for a longer time. If you remove the bracket and rewrite it the predictive text should appear again.

But more helpful could be the Object Catalouge



来源:https://stackoverflow.com/questions/49506773/predictive-text-for-vba-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!