나는 매일 다른 엑셀 시트에서 데이터를 수집하고 하루에 한 번만 계산을 수행하는 파일을 만듭니다. 이 파일이 생성되면이 파일은 하루에 다른 시간에 사용됩니다. 이 파일은 아직 존재하지 않는 경우 매크로에 의해 생성됩니다. 파일을 열면 화면에 표시됩니다. 모든 파일 열기를 숨기기 위해 숨겨진 상태로 유지되는 두 번째 Excel 인스턴스를 만들었습니다. 문제는 두 번째 인스턴스의 시트에 테이블을 만들 수 없다는 것입니다.
다음은 코드입니다.
Dim app As New Excel.Application
app.Visible = False
Set newWB = app.Workbooks.Add
With newWB
.Title = "Summarizing of systemparts information"
.Subject = "Systemparts"
.SaveAs assembledSheet
End With
app.newWB.Sheets("SystemParts").ListObjects.Add(xlSrcRange, Range("$A$1:$CN$55"), , xlYes).Name = "SystemP"
app.ActiveSheet.ListObjects("SystemP").TableStyle = "TableStyleLight8"
이 문제를 해결할 수있는 옵션이 있습니까?
아직 만들지 않은 시트에 표를 추가하려고합니다. 새 통합 문서를 만들지 만 'SystemParts'시트를 지정하지 못했습니다.
Sub Test()
Dim app As Excel.Application
Dim newWB As Workbook
Dim newWS As Worksheet
Dim x As Long
'Create new Excel instance and add a new workbook.
Set app = New Excel.Application
Set newWB = app.Workbooks.Add
With newWB
'Add a sheet to the end of the workbook.
Set newWS = .Worksheets.Add(, .Worksheets(.Worksheets.Count))
'Remove all other sheets.
'As you delete sheet Index 1 - the next sheet replaces it,
'so just remove the first index each time.
Application.DisplayAlerts = False
For x = 1 To .Worksheets.Count - 1
.Worksheets(1).Delete
Next x
Application.DisplayAlerts = True
'Name the new sheet and add a table.
With newWS
.Name = "SystemParts"
.ListObjects.Add(xlSrcRange, .Range("$A$1:$CN$55"), , xlYes).Name = "SystemP"
.ListObjects("SystemP").TableStyle = "TableStyleLight8"
End With
.SaveAs ThisWorkbook.Path & "\NewWB.xlsx"
End With
End Sub
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다