Bonsoir,
voilà je cherchais comme tant d'autre à modifier un champ texte dans word à l'aide de la fonction range.
Tout se passe bien mais l'index est écrasé au moment du changement. Or, je ne peux pas me permettre de perdre les index du documents même après modification puisqu'ils sont réutilisés dans une autre appli derrière
J'ai essayé d'tiliser la fonction select ... mais je n'arrive pas non plus à de bon resultats.
j'ai vu des codes sur la fonction select qui passent en suite à une autre (selection) que je n'arrive pas non plus à intégrer dans mon code
voici ce que j'ai fait:
peut on conserver l'index ? si non peut on le recréer juste au moment de sa destruction ?
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
26
27
28
29
30
31
32
33
34
35 Dim oW As Microsoft.Office.Interop.Word.Application Dim OwD As Microsoft.Office.Interop.Word.Document Dim oWr As Microsoft.Office.Interop.Word.Range oW = New Microsoft.Office.Interop.Word.Application OwD = oW.Documents.Open("C:\Users\florent\Documents\MANU_DEV\HLMPROSUITS\MODELES\PUB_MODEL1.docx", [ReadOnly]:=False) ' Initialisation de la variable OwD.Bookmarks.Item("texte19").Range.Text = Today oWr.range.Text = Today 'CECI EFFACE L INDEX oWr = OwD.Bookmarks.Item("texte3").Range oWr.Text = TextBox40.Text oWr = OwD.Bookmarks.Item("texte4").Range oWr.Text = Label51.Text oWr = OwD.Bookmarks.Item("texte26").Range oWr.Text = Label52.Text oWr = OwD.Bookmarks.Item("texte6").Range oWr.Text = TextBox5.Text & " " & TextBox6.Text If Label65.Text = "Appartement" Then OwD.FormFields("CaseACocher2").CheckBox.Value = True ElseIf Label65.Text = "Maison" Then OwD.FormFields("CaseACocher1").CheckBox.Value = True Else oWr = OwD.Bookmarks.Item("texte12").Range oWr.Text = Label65.Text End If oW.Visible = True
merci de votre aide
Partager