Astuce du Jour dans l'Editeur VBA !

Creepy

XLDnaute Accro
Bonsoir à vous tous,

J'ai découvers par hasard dans l'editeur VBA une combinaison de touche fort pratique.

Admettons que vous ayez une macro comme suit :

Sub test()
Code...
...
Call Remplir_les_cellules
end sub

Et bien vous surlignez 'Remplir_les_cellules' en double cliquant dessus et vous faites SHIFT + F2 et là .....

Abracadabra vous allez directement à la routine Sub Remplir_les_cellules !! Génial et pour revenir : CTRL + SHIFT + F2 et hop retour à la procédure test !!!

Je connaissais pas j'ai trouvé par hasard !! Depuis je ne peu plus m'en passer :woohoo:

@+

Creepy

PS : Je sais pas trop si ce type de post à sa place ici ou dans le salon, toujours est-il que je pense que plus de personne le verrons ici. Désolé s'il devait être dans le salon
 

Creepy

XLDnaute Accro
Re all,

Ba la commande Call XXXX c'est pour appeller une procédure ou une function plus loins dans le code.

Ce permet de suivre ton code et eventuellement d'aller directement à la procedure sasn avoir à jouer avec la scroll barre pendant 2 mn !

C'est imagé mais c'est ca !

++

Creepy

PS : Ca nesert à rien, mais comme dit le dictopn :

'Tout ce qui est inutile est indispensable !' :p

Message édité par: Creepy, à: 24/08/2005 19:06
 

tontoncarton

XLDnaute Occasionnel
bijour ,

youpi c'est de la balle ton truc fini les petits tours d'ascenseur !!!!

merci pour l'info :) @+

j'en profite pour poser une chtite question ,tant qu'on est dans le sujet simplifie moi la vie lol

j'ai cru comprendre qu'on pouvais utiliser la molette dans vba pour faire defiler le code mais alors comment, ca je sais pas ??

merci si qq'un tombe sur ma question @ ++++ :)
 

Ti_

Nous a quitté
Repose en paix
Tiens, ça me rappelle que j'avais trouvé ça un jour, au hasard de mes recherches sur le net. Ca s'applique au VB, mais ça marche aussi dans l'éditeur VBA :

http://www.vbrad.com/Source/tip_Stupid_Keyboard_Tricks.htm

Many people don't realize that using the keyboard will make you a ton more productive than using a mouse to achieve the same goals. This is particularly true for the Visual Basic IDE. And even though most of the keyboard shortcuts are described in the help file, I see programmer after programmer using the mouse to do the keyboard's job. All these shortcuts apply to VB6. However, most of them will also work with VB5 and some will go even lower. So without further delay, here is your guide to being more productive. Later, check out the section on how to discover your own shortcuts.

• When typing code, use the Code Completion feature. For instance, consider the following code:
Dim strEmployeeName as String
Dim lngEmployeeID as Long
When typing strEmployeeName you can save yourself a couple of seconds by typing strE and then pressing Ctrl-Space to signal Visual Basic to complete your variable. That is right, VB will append mployeeName to strE, to complete strEmployeeName . Pretty nifty, ha? The reason this happens is because VB keeps all the variables, functions, subs, methods, etc... in memory and can pop them up whenever necessary. If you get into the habit of using this feature, you'll shave off hours from you development time just in a single week.

• If Visual Basic finds more than one match to what you typed, it will display a popup list for you to choose from. This is handy with long object names that have large object hierarchies. For instance, instead of typing in strE we typed str. Obviously there are tons of functions that match str. So VB drops down a box that lets you select. Eventually you will get into a habit of creating drop-down friendly variables (so that there are less items in the dropdown) and that will speed up the coding even further.

• Here is really cool one pointed out by HENRI VAN DER WESTHUIZEN of South Africa. While in the Properties screen, just type CTRL-SHIFT and the first letter of the property and you will go straight to it. A lot easier that scrolling through all of them to get to the bottom one.

• Below is a whole slew of keyboard tricks contributed by a fellow keyboard jockey Greg Heslington. I have to admit, some of them caught me by surprise. Furthermore, Greg provided us with an excellent Excel spreadsheet listing various the VB shortcuts in a template manner, a la those WordPerfect 5.1 paper templates that were placed on the F keys. Anyway, without further delay, here are Greg's tricks:

• Code Window Shortcuts
- Ctrl+F2 (5 star tip) - moves focus to the 'Object' combo-box above the Code window. ...from here you can select the procedure you're editing by using DownArrow to drop-down the combo-box's list of objects. Press the first letterof the object name, or UpArrow/DownArrow/Home/End to navigate through the list. Home is good for selecting the (General) section, where non-event-code procedures live. Then, press Tab to toggle between the 'Object' and 'Procedure' combo-boxes and navigate similarly. Press Return to selectone, and you'll be back in the Code window at the correct position.
- Ctrl+Shift+F2 - I mentioned this one before. Greg adds that it works without first pressing Shift+F2, as it cycles through the last 8 positions visited, not just where you were before you viewed the definition of a variable.
- F3 - find the next occurrence of text last searched for
- Shift+F3 - find the previous occurrence of text last searched for
- Ctrl+F3 - find the next occurrence of selected text, or the word under the cursor
- Ctrl+Shift+F3 - find the previous occurrence of selected text, or the word under the cursor
- The general rule-of-thumb for the previous four is as follows: 'Press shift to search backwards; press ctrl to start searching for something different'.
- F6 - (when the Code window is split into two panes) - toggles between the panes. To split the panes first (or indeed un-split afterwards), press alt+W, P.
- Ctrl+Shift+F9 - clear all breakpoints
- Tab (when a block is selected) - indent the whole block
- Shift+Tab (when a block is selected) - un-indent the whole block
- Ctrl+Z - undo the last change. The last 20 changes can be backed out of.
- Ctrl+I - show the quick-info tooltip. Tells you the type of variable,or value of a constant, at the cursor.
- Ctrl+Shift+I - show the parameter-info tooltip. Tells you the parameters required in a function or sub call, without having to insert a spurious comma and delete it! (which you can't do anyway in modules that are marked as read-only).
- Ctrl+G - show the Immediate window.
- Ctrl+F - show the Find dialog
- Ctrl+H - show the Replace dialog
- ...within Find and Replace dialogs, the highlighted text (or the word underthe cursor is automatically placed in the Find What field). Press Return to Find Next, Esc to close the dialog, or alt+letter to focus and/or toggle onthe other controls [duh...?]
- Ctrl+Y - remove the current line without having to select it. This one was contributed by Joacim Andersson.

• Object window shortcuts (i.e. the forms)
- Shift+F4 - show the custom property pages for the selected object
- Arrow keys - UpArrow/DownArrow/LeftArrow/RightArrow
- Select a different control on the container.
- With Shift pressed, enlarge/shrink the selected control(s).
- With Ctrl pressed, move the selected control(s) around the container.
- Tab or Shift-Tab - select the next/previous control in the tab order

• Project Explorer window
- Tab - switch between projects in a group
- Down Arrow - move down the tree
- Up Arrow - move up the tree
- Right Arrow - expand a folder, or go to the first child node
- Left Arrow - collapse (if a folder) and go to the parent node
- Numeric Plus - expand the folder
- Numeric Minus - collapse the folder

• Property window
- Tab or Shift+Tab - cycle forwards/backwards through the control drop-down, the tabs, the property name, and the property value. This method can be useful for changing (or just reviewing) several control's properties, eg the TabIndexes (TabIndices? :). Useful if certain controls are on hidden areas of the form (eg on different tabs of your form) andyou don't want to hunt them down and click (ugh!) on them.
- The 'Categorized' tab in Properties is dead useful for hiding the other properties if you're reviewing the sizes of your controls. Just click on all the minus signs except for the one next to the 'Position' category. Did I say click?! I meant Tab to a property category, press LeftArrow to collapse it, then press DownArrow to move down to the next property category.

• Break Mode
- Shift+F5 - re-run from the start (surely not that useful?)
- F8 - step into the current statement
- Shift+F8 - step over the current statement
- Ctrl+F8 - run upto the statement under the flashing cursor
- Ctrl+Shift+F8 - run the rest of the current procedure and break againwhen exiting back to the calling statement
- F8 based shortcuts can also be used from design mode, to start the project and immediately single-step through the code, but I can imagine that stepping through the start-up code of a big project would be very tedious. In fact I bet you'd get a misleading impression of the program flow, because break mode tends to suppress certain events from firing.
- Ctrl+F9 - set the statement under the flashing cursor as the next one to execute.
- Ctrl+L - view (and navigate) the call stack

• Miscallaneous
- Ctrl+F4 - close the current child window (as per bog-standard Windows)
- Ctrl+F6 or Ctrl+Tab (or with Shift) - cycle forwards/backwards through the Code windows and Object windows
- Shift+F7 - go to the Object window. This is the complement of F7 whichyou mentioned.
- You want to make more space for the Code window while programming? Hiding the Project Explorer, Properties and Immediate windows is easy:- Ctrl+R, menu, H to hide the Project Explorer window, F4, menu, H to hide the Properties window, Ctrl+G, menu, H to hide the Immediate window.
- Not necessarily a keyboard shortcut for VB so much as Windows in general; any ListView (Explorer folders included) which is in report (ie, details) view can have its column widths auto-resized by pressing Ctrl+NumericPlus.

• There are many more simple keyboard shortcuts that for some reason are seldom used by programmers. Below are some of them:
Place the cursor on a function name, then press Shift-F2 combination and it will take you to that function.
Press Ctrl-Shift-F2 and it will take you back. These two combos have been there since the dawn of VB.
Have you ever lost the Project Explorer window? Press Ctrl-R to bring it to life.
Do a quick save before running. Press Ctrl-S.
Never select Start button. Always do a Start With Full Compile. Either press Ctrl-F5 or hold down the Ctrl key while pressing the Start button. (Or as some of my less than competent co-workers call it: The 'Play' button).
Want to do a quick comment/uncomment of your code? See this tip.
Do you want to quickly see the value of a variable? Place a cursor on the variable and press Shift-F9.
To toggle a breakpoint, use F9.
Ctrl-A will select all the code in the Code Window. BTW, if you didn't know this one, please pack up your copy of VB and return it to the store for a full refund. You don't deserve to be a programmer.
Are you sick and tired of going to the Project menu and selecting Components? Simply press Ctrl-T.
To bring up properties for any object in VB, press F4. To bring up code, press F7 on any object.
 

Humansoft

XLDnaute Occasionnel
Bonsoir le forum, bonsoir à tous

Une autre façon d'aller d'une procédure à l'autre.
Il suffit de mettre sa souris sur le nom de la procédure, bouton droit de la souris, définition et hop nous y v'la

Pour le retour, bouton droit dans la procédure, dernière position et clac nous y r'vient

Pour la molette, il existe un petit fichier que je vous joint sur ce post.
Cela permet le scroll à la souris dans le code VBA et cela fonctionne aussi avec Visual Basic

Je l'utilise depuis + de 6 mois et c'est génial

Vincent
[file name=VBScroll.zip size=26503]http://www.excel-downloads.com/components/com_simpleboard/uploaded/files/VBScroll.zip[/file]
 

Pièces jointes

  • VBScroll.zip
    25.9 KB · Affichages: 172
  • VBScroll.zip
    25.9 KB · Affichages: 177
  • VBScroll.zip
    25.9 KB · Affichages: 176

Discussions similaires

Statistiques des forums

Discussions
312 195
Messages
2 086 078
Membres
103 111
dernier inscrit
Eric68350