2016-10-28 3 views
0

매일 다른 엑셀 시트에서 데이터를 수집하고 하루에 한 번만 계산하는 파일을 만듭니다. 이 파일을 만들면이 파일은 하루에 여러 번 사용됩니다. 이 파일은 매크로가 아직 작성하지 않은 경우 작성됩니다. 파일을 열면이 파일이 화면에 표시됩니다. 모든 파일을 숨기려면 숨겨진 두 번째 엑셀 인스턴스를 만들었습니다. 문제는 두 번째 인스턴스의 시트에 테이블을 만들 수 없다는 것입니다. 이 문제를 해결 할 수있는 옵션이다른 엑셀 응용 프로그램에 테이블 추가

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" 

있습니까 :

코드인가?

+0

새 Excel 인스턴스를 여는 대신 시작시 'Application.ScreenUpdating = False'를 사용할 수 있습니다 ... 그리고 나서 코드의 끝에서 다시 켜십시오. – Rdster

+0

다른 파일을 여는 데는 해당되지 않습니다. 백그라운드에서 다른 Excel 파일이 열리는 것을 사용자에게 숨기고 싶습니다. –

답변

0

아직 작성하지 않은 시트에 표를 추가하려고합니다. 새 통합 문서를 만들었지 만 '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 
관련 문제