1
Excel 2010 VBA를 사용하여 프로그래밍 방식으로 Word 2010 문서를 생성하고 있습니다.
삽입 한 단락 (아래 코드의 5 행) 중 하나에 ListTemplate을 적용하려고하면 프로그램이 중단됩니다.ListTemplate 적용 후 MS Word가 충돌 함
thisValue = tempSheet.Cells(i, 1).Value
.Content.InsertAfter thisValue
.Content.InsertParagraphAfter
Set thisRange = .Paragraphs(i).Range
thisRange.ListFormat.ApplyListTemplate ListTemplate:=ListGalleries(wdBulletGallery).ListTemplates(1)
발생 된 오류는 다음과 같습니다
는런타임 오류 "-2147023170 (800706BE)"
자동화 오류
원격 프로 시저 호출이 실패했습니다.
전체 절차 :
Sub MoveDataToWord(ByRef tempSheet As Worksheet)
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Add
With wrdDoc
For i = 1 To tempSheet.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
thisValue = tempSheet.Cells(i, 1).Value
.Content.InsertAfter thisValue
.Content.InsertParagraphAfter
Set thisRange = .Paragraphs(i).Range
thisRange.ListFormat.ApplyListTemplate ListTemplate:=ListGalleries(wdBulletGallery).ListTemplates(1)
Next i
End With
Set wrdDoc = Nothing
Set wrdApp = Nothing
End Sub
늦은 구속력이 있습니까? 늦은 바인딩을 사용한다면'wdBulletGallery'를'1'로 바꾸고 다시 시도하십시오. –
내가 늦었거나 초기 바인딩인지 확실하지 않아 Excel에서 전화를 걸었습니다. 어쨌든, 나는 1 대신에 그것을 테스트했고 같은 에러를 받았다. – user984165
코드 구문이 정확합니다. 전체 절차를 볼 수 있습니까? –