2014-06-18 2 views
0

나는 다음과 같은 스크립트가 : 두 번째 시트값을 저장하기

Set fso = CreateObject("Scripting.FileSystemObject") 
Set xl = CreateObject("Excel.Application") 
xl.Visible = True 'set to False for production 
Set wb = xl.Workbooks.Open("C:\XXXSample_Data.xlsx") 'xl.Workbooks.Open(f.Path) 
Set ws = wb.Sheets("XXXXX") 
Set objRE1 = New RegExp 
    With objRE1 
     .Pattern = "Invalid Response received from system" 
     .IgnoreCase = True 
     .Global  = False 
    End With 

    Set objRE2 = New RegExp 

    With objRE2 
     .Pattern = "Enterprise Data mapping cannot be found" 
     .IgnoreCase = True 
     .Global  = False 
    End With 

    Set objRE3 = New RegExp 

    With objRE3 
     .Pattern = "Caught exception and rethrowingError detected" 
     .IgnoreCase = True 
     .Global  = False 
    End With 

    xf = 0 
    re = 0 
    gg = 0 
    rst = 0 

    For Each cell In ws.UsedRange.Columns(11).Cells 
     str = cell.Value 
     If objRE1.Test(str) Then 
       xf = xf + 1 
     Elseif objRE2.Test(str) Then 
       re = re + 1 
     Elseif objRE3.Test(str) Then 
       gg = gg + 1 
     Else 
       rst = rst + 1 
     End If  
    Next 

    Set objWorksheet = xl.ActiveWorkbook.Worksheets(2) 
    objWorksheet.Cells(5,5).Value = "Invalid Response received from system " 
    objWorksheet.Cells(6,5).Value = "Enterprise Data mapping cannot be found " 
    objWorksheet.Cells(7,5).Value = "Caught exception and rethrowingError detected " 
    objWorksheet.Cells(8,5).Value = "Errors With new String patterns found " 

    'WScript.Echo xf 
    objWorksheet.Cells(5,6).Value = xf 
    objWorksheet.Cells(6,6).Value = re 
    objWorksheet.Cells(7,6).Value = gg 
    objWorksheet.Cells(8,6).Value = rst 

    wb.Saved = True 
    wb.Close 

Set objRE1 = Nothing 
Set objRE2 = Nothing 
xl.Quit 

값은 서면 또는 저장하기되지 않습니다.

다른 점 - 파일이 어떻게 든 "내 문서"아래에 저장되는 것을 볼 수 있습니다. 누군가가 지적 할 수도 있습니다.

답변

1
wb.Save 
wb.Close true, "C:\XXXSample_Data.xlsx" 

설정 wb.Saved = True 저장하지 않고 저장 한 것으로 표시합니다. Close

매개 변수는 다음과 같습니다 변경

저장 될 파일을 변경 ( true) 및 경로를 저장
관련 문제