Preference settings
The following sections explain how you can make Code VBA match the way you work.
- Show Code Explorer
- Hide FUNCRES.XLAM
- Hide Set for own Application
- Show Tooltip on MouseHover
- Customize the Code VBA toolbar
- Choose Early or Late Binding
- Whether or not to use Named Arguments
- Use short syntax for Item in Collection
- Insert Enum Values as
- Add Fragment Title
- Change variable prefixes and names of return variables
- Edit Boolean Expressions
- Allow look for new version
Alt-CP | Menu: Code VBA » Preferences » |
Show Code Explorer
Show or hide the Code Explorer
Hide FUNCRES.xlam
Having FUNCRES.xlam in Code Explorer is confusing, clutters it and has no purpose. That is why we chose to hide it.
Hide Set for own Application
Decide if you want in the Application Object submenu to have a 'Set' menu item present, allowing you to instantiate an Application object variable. Usually you will do without it because it is globally available.
Show Tooltip on MouseHover
This setting determines if a tooltip appears when you hover over a menu item - if info is available. The tooltips are a very useful source of information for classes and procedures you are not familiar with. However if you access the menu mainly using the mouse, the constant appearance of tooltips may get in the way. In that case you may be better of un-checking the preference 'Show Tooltip on MouseHover'.
Tip: F1 |
---|
Pressing F1 makes a tooltip available that shows the what procedure code will be inserted and a description of the procedure or class - if available. If you see the text hyperlinked you can press F1 again which opend the relevant help page in the browser. |
Control-Space use Code VBA InstelliSense
If checked, the more extensive and context sensitive shortcut menu Code VBA InstelliSense menu replaces the VBE built-in approach.
What should inserted code look like
When code VBA inserts a procedure statement it uses certain decisions which you can change here. As an exampl, take the function left
Alt-CVSL | Menu: Code VBA » VBA » String » Left |
Dim strString As String: strString =
Dim strLeft As String
strLeft = Left(String:=strString, Length:= )
By removing the check for 'Named Arguments' different code:
str = Left()
You most benefit of Code VBA if you always use the default, Early Binding. If you check Choose ..., each time you want to use an unreferenced application or library (for the first time) you will be asked if you want Early or Late Binding.
Named Arguments (Explicit)
In the above example the preference 'Named Arguments' determines if the code String:=
and Length:=
gets inserted
Explicit Arguments are useful to clarify what a procedure argument is used for. It makes the code self documenting.
Use short syntax for Item in Collection
When checked, the result is:
Set wb = Application.Workbooks()
Alternatively, the method Item is explicit.
Add Fragment Title
When inserting a code fragment you may want to have your code documented with an extra line filled with the title of the fragment.
'Fill array with files using Dir and FileSpec''
Dim FileSpec As String
...
Prefixes for variables
Alt-CPC | Menu: Code VBA » Preferences » Change prefixes |
The variable prefixes are stored in a text file. If for a type the prefix is not to your liking, you can add or change it here.
Return Variable Names
Alt-CPR | Menu: Code VBA » Preferences » Return Variable Names |
When a user selects a function, the name of the function is added to the type prefix to construct a name for the variable. If the variable name created is not helpful, you can change it.
As an example, in the code below the return variable for the function Left is constructed from the type prefix str
and the function name Left
giving the meaningful name strLeft
.
Dim strString As String: strString =
Dim strLeft As String
strLeft = Left(String:=strString, Length:=)
If you use a specific function regularly you can change the returned name by adding an appropriate line in the 'returnvarnames.txt' text file which is opened by clicking this preference. Below show too added lines.
Environ=
means 'don't try to name the variable to Environ'. The reason for not wanting this variable name is this function will return totally different things depending on the argument passed to the function.Format=Formatted
means 'use Formatted instead of Format'. The reason for is that Formatted describes what is returned whil Format is to close to the action that produced it.