逐步调试崩溃VBA
我的宏有问题,然后我想使用逐步进行调试(使用F8),但是当我输入此过程时,我的逐步崩溃了,宏(带有错误)
Option Explicit
Private Sub create_fsm_Cliquer()
Dim MaFeuille As Worksheet
Dim nombre_de_vdd As Integer
Dim nom_fichier_sauvegarde As String
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim nb_ligne As Integer
Dim dernier_rev As String
Dim word_fichier As Document
Dim fichier As String
Dim word_app As Word.Application
Dim fs As Object
Dim reponse As Object
Dim footr As Object
Set MaFeuille = Sheets("Info FSM")
dernier_rev = MaFeuille.Cells(5, 2)
nombre_de_vdd = MaFeuille.Cells(2, 2)
nb_ligne = Cells.Find("*", [A1], , , , xlPrevious).Row
fichier = ActiveWorkbook.Path & "\" & "fsm_template_balises.docx"
Set word_app = CreateObject("Word.Application")
With word_app
.Visible = True
.WindowState = 1
End With
Set word_fichier = word_app.Documents.Open(fichier)
For i = 14 To nb_ligne
For Each footr In word_fichier.Sections(1).Footers
With footr.Range.Find
.Text = MaFeuille.Cells(i, 1)
.Replacement.Text = MaFeuille.Cells(i, 2)
.Execute Replace:=wdReplaceAll
End With
Next footr
Next i
nom_fichier_sauvegarde = ActiveWorkbook.Path & "\" & "fsm_template_balises_" & dernier_rev & ".docx"
Set fs = CreateObject("Scripting.FileSystemObject")
If (fs.FileExists(nom_fichier_sauvegarde)) Then
reponse = fs.DeleteFile(nom_fichier_sauvegarde, True)
End If
word_fichier.SaveAs nom_fichier_sauvegarde
word_fichier.Close
word_app.Quit
End Sub
我的宏崩溃了。到达线 .replacement.text = mafeuille.cells(16,2)
edit:IM使用Excel宏来处理.docx
编辑:结果是我的第一个页脚很好,但其他人是与执行之前一样
i have a problem in my macro then i wanted to debug it using step by step (using F8) but when i enter in this, my step-by-step crashed and the macro finished (with bugs)
Option Explicit
Private Sub create_fsm_Cliquer()
Dim MaFeuille As Worksheet
Dim nombre_de_vdd As Integer
Dim nom_fichier_sauvegarde As String
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim nb_ligne As Integer
Dim dernier_rev As String
Dim word_fichier As Document
Dim fichier As String
Dim word_app As Word.Application
Dim fs As Object
Dim reponse As Object
Dim footr As Object
Set MaFeuille = Sheets("Info FSM")
dernier_rev = MaFeuille.Cells(5, 2)
nombre_de_vdd = MaFeuille.Cells(2, 2)
nb_ligne = Cells.Find("*", [A1], , , , xlPrevious).Row
fichier = ActiveWorkbook.Path & "\" & "fsm_template_balises.docx"
Set word_app = CreateObject("Word.Application")
With word_app
.Visible = True
.WindowState = 1
End With
Set word_fichier = word_app.Documents.Open(fichier)
For i = 14 To nb_ligne
For Each footr In word_fichier.Sections(1).Footers
With footr.Range.Find
.Text = MaFeuille.Cells(i, 1)
.Replacement.Text = MaFeuille.Cells(i, 2)
.Execute Replace:=wdReplaceAll
End With
Next footr
Next i
nom_fichier_sauvegarde = ActiveWorkbook.Path & "\" & "fsm_template_balises_" & dernier_rev & ".docx"
Set fs = CreateObject("Scripting.FileSystemObject")
If (fs.FileExists(nom_fichier_sauvegarde)) Then
reponse = fs.DeleteFile(nom_fichier_sauvegarde, True)
End If
word_fichier.SaveAs nom_fichier_sauvegarde
word_fichier.Close
word_app.Quit
End Sub
My macro crashed when the step-by-step reached the line.Replacement.Text = MaFeuille.Cells(16, 2)
Edit : im using an excel macro to work on a .docx
Edit : the result is that my first footer is good, but the others are the same as before the execution
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论