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 36 37 38
| 'j'exporte le userform1 et nomme le fichier en incrémentant le n°, le nombre de userform de navigateur internet est noté dans la textbox3
ThisWorkbook.VBProject.VBComponents("Userform1").Export "C:\Userform" & TextBox3.Text + 1 & ".frm"
'j'ouvre le fichier frm ainsi généré pour le lire et en créé un autre afin de modifier dans le frm final les deux occurrences qui mentionnent le nom réel du userform
Open "C:\Userform" & TextBox3.Text + 1 & ".frm" For Input As #1
Open "C:\Userform" & TextBox3.Text + 1 & "final.frm" For Output As #2
While Not EOF(1)
Line Input #1, get_line
If Left(get_line, 17) = "Attribute VB_Name" Then
Print #2, Left(get_line, 21) & "UserForm" & TextBox3.Text + 1 & Right(get_line, 1)
End If
If Right(get_line, 10) = "UserForm1 " Then
Print #2, Left(get_line, Len(get_line) - 10) & "UserForm" & TextBox3.Text + 1 & " "
End If
If Left(get_line, 17) <> "Attribute VB_Name" And Right(get_line, 10) <> "UserForm1 " Then
Print #2, get_line
End If
Wend
Close #1
Close #2
'j'incrémente le nombre de userform de navigateur dans la textbox3
TextBox3.Text = TextBox3.Text + 1
'j'importe le FRM final dans mon classeur
ThisWorkbook.VBProject.VBComponents.Import "C:\Userform" & TextBox3.Text & "final.frm"
'je détruit les fichiers temporaires
Kill "C:\Userform" & TextBox3.Text & ".frm"
Kill "C:\Userform" & TextBox3.Text & ".frx"
Kill "C:\Userform" & TextBox3.Text & "final.frm"
Kill "C:\Userform" & TextBox3.Text & "final.frx" |
Partager