Bonjour à tous,
je crée un formulaire avec de multiples champs dans Word 2013 et je bute sur un problème.
Je souhaite vraiment éviter que les utilisateurs ne me mettent le fou...bazar dans le formulaire et de ce fait, j'aimerais que la touche Entrée ne serve pas à ajouter une ligne, mais à se comporter comme la touche Tab et change de ce fait de champs de formulaire.
J'ai essayé de copier cette Macro dans la partie "ThisDocument" en mode VBA :
Et en fait, et bien... ça ne fonctionne pas... mais du tout...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 Sub EnterKeyMacro() ' Check whether the document is protected for forms ' and whether the protection is active. If ActiveDocument.ProtectionType = wdAllowOnlyFormFields And _ Selection.Sections(1).ProtectedForForms = True Then ' Retrieve the bookmark of the current selection. ' This is equivalent to the name of the form field. myformfield = Selection.Bookmarks(1).Name ' Go to the next form field if the current form field ' is not the last one in the document. If ActiveDocument.FormFields(myformfield).Name <> _ ActiveDocument.FormFields(ActiveDocument.FormFields.Count) _ .Name Then ActiveDocument.FormFields(myformfield).Next.Select Else ' If the current form field is the last one, ' go to the first form field in the document. ActiveDocument.FormFields(1).Select End If Else ' If the document is not protected for forms, ' insert a tab stop character. Selection.TypeText Chr(13) End If End Sub
Faut-il que je fasse autre chose ? Ou avez-vous une autre idée ?
Je vous mets le fichier pour plus de clarté (il est tout moche et incomplet, mais c'est normal, j'ai viré plein de choses )
PLAN DE PREVENTION2.doc
Merci par avance et bonne journée !
Esk
Partager