아래 코드에서 HwpCtrl1.Open strMain 에서 자꾸 429 런타임오류, 개체가 필요합니다만 나오네요.
참고로 저는 컴맹입니다.
Private Sub UserForm_Activate()
'변수설정
Dim strFile As String, strHwp As String, strMain As String '엑셀파일,한컴파일,한컴양식파일 주소
Dim strFolder As String, strFileName As String '불러 올 폴더주소, 파일이름
Dim opFile As Workbook '불러 올 엑셀파일
Dim CellAd As String '셀 주소
Dim CountRow As Long '행 개수
Dim i As Double
Dim vAct As HwpAction
Dim vSet As HwpParameterSet
Dim titleCS As String
'폴더열기
With Application.FileDialog(msoFileDialogFolderPicker)
.Show
If .SelectedItems.count = 0 Then Exit Sub
strFolder = .SelectedItems(1)
End With
strFileName = Dir(strFolder & "\*.xls*")
Do While strFileName <> ""
strFile = strFolder & "\" & strFileName
Workbooks.Open strFile
Set opFile = ActiveWorkbook
strHwp = Left(opFile.FullName, Len(opFile.FullName) - 5) & ".hwp"
'한컴 양식파일 열기
strMain = ThisWorkbook.Path & "\Main.hwp"
HwpCtrl1.Open strMain
'행 개수 세기
CellAd = opFile.Sheets(1).Range("A5")
CountRow = 0
Do While CellAd <> ""
CountRow = CountRow + 1
CellAd = opFile.Sheets(1).Range("A" & CountRow + 5)
Loop
'제목 변경
titleCS = opFile.Sheets(1).Range("A2")
Set vAct = HwpCtrl1.CreateAction("AllReplace")
Set vSet = HwpCtrl1.CreateSet("FindReplace")
vAct.GetDefault vSet
vSet.SetItem "FindString", "제목!"
vSet.SetItem "ReplaceString", titleCS
vSet.SetItem "IgnoreMessage", True
vAct.Execute vSet
'표 추가
Set vAct = HwpCtrl1.CreateAction("TableInsertLowerRow")
Set vSet = vAct.CreateSet
vAct.GetDefault vSet
vSet.SetItem "TableInsertLine", 1
For i = 1 To CountRow - 1
vAct.Execute vSet
Next i
'복사 붙여넣기
opFile.Sheets(1).Range("A5:G" & CountRow + 4).Copy
Set vAct = HwpCtrl1.CreateAction("Paste")
Set vSet = vAct.CreateSet
vAct.GetDefault vSet
vSet.SetItem "Option", 5
vAct.Execute vSet
Application.CutCopyMode = False
'저장
HwpCtrl1.SaveAs strHwp
opFile.Close SaveChanges:=False
strFileName = Dir()
Loop
End Sub