2016-08-22 35 views
-1

vbスクリプトを実行するタスクスケジューラを使用してバッチファイルを実行しようとしています。スクリプトを手動で実行するか、Windows 7の タスクスケジューラから実行したときに正常に動作しますが、 手動で実行するか、Windows Server 2012 R2のタスクスケジューラから集中管理されたサーバーの場所から実行しようとすると、エラー: マイクロソフトのVBScriptランタイムエラー:ActiveXコンポーネントはオブジェクトを作成できません: 'まずExcel.Application'Windows 2012のActiveXコンポーネントエラー

これは私のバッチスクリプトコードです:

cscript %~dp0\CSV_To_Excel.vbs %1 

これは私のExcelのコード(ExcelにCSVに変換)であります:

Dim Excel 

file = "C:Folder1\Customer.csv"  
Set fso = CreateObject("Scripting.FileSystemObject") 

txt = fso.OpenTextFile(file).ReadAll 

fso.OpenTextFile(file, 2).Write Replace(Replace(txt, "¬", vbTab), Chr(34), "") 

'Set obj = CreateObject("Scripting.FileSystemObject") 'Calls the File System Object 

Const xlDelimited = 1 
Const xlNormal = -4143 

Set Excel = CreateObject("Excel.Application") 
Excel.DisplayAlerts = False 
With Excel 
    .Workbooks.Open "C:Folder1\Customer.csv" 
    .Sheets(1).Columns("A").TextToColumns .Range("A1"), xlDelimited, , , , True 'semicolon-delimited 

    .ActiveWorkbook.SaveAs .ActiveWorkbook.Path & "\Customer", xlNormal 
     'Excel.Saved = True 
     'Excel.Close 
    .Quit 
Excel.DisplayAlerts = True 

    fso.DeleteFile("C:Folder1\Customer.csv") 'Deletes the file throught the DeleteFile function 
End With 

ありがとう

答えて

関連する問題