Excel 파일 외부에서 Excel 매크로를 실행하려고합니다. 현재 명령 줄에서 실행되는 ".vbs"파일을 사용하고 있지만 매크로가 발견되지 않는다고 계속 알려줍니다. 여기에 내가 여기외부 Excel에서 Excel 매크로를 명령 줄에서 VBScript를 사용하여 실행하십시오.
Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("test.xls")
objExcel.Application.Visible = True
objExcel.Workbooks.Add
objExcel.Cells(1, 1).Value = "Test value"
objExcel.Application.Run "Macro.TestMacro()"
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit
WScript.Echo "Finished."
WScript.Quit
를 사용하려고 그리고있어 스크립트는 내가 접근에 노력하고있어 매크로입니다 : 내가 Is it possible to run a macro in Excel from external command?에있는 솔루션은 여기까지를 얻기 위해 노력
Sub TestMacro()
'first set a string which contains the path to the file you want to create.
'this example creates one and stores it in the root directory
MyFile = "C:\Users\username\Desktop\" & "TestResult.txt"
'set and open file for output
fnum = FreeFile()
Open MyFile For Output As fnum
'write project info and then a blank line. Note the comma is required
Write #fnum, "I wrote this"
Write #fnum,
'use Print when you want the string without quotation marks
Print #fnum, "I printed this"
Close #fnum
End Sub
(수정 물론) 작동하지 않는 것 같았다. Microsoft Office Excel : 매크로 'Macro.TestMacro'를 찾을 수 없습니다.
편집 : Excel 2003.
당신이 제거하려고 했나 "매크로." 및/또는 괄호를 사용하고 objExcel.Application.Run "TestMacro"와 같이 호출하십시오. – deusxmach1na
objExcel.Application.Run "test.xls! Macro.TestMacro" –
둘 다 작동하지 않습니다. ( – muttley91