본문 바로가기
Programming/Macro(Excel, Google Sheets)

Excel VBA를 이용하여 CST STUDIO SUITE 이용하기 (Using CST STUDIO SUITE with Excel VBA)

by 도파공 2022. 11. 13.
728x90
반응형

Excel VBA ActiveX 컨트롤러를 이용하여 CST STUDIO SUITE을 제어할 수 있다. 아래의 내용은 기본 사례이다.

You can control CST STUDIO SUITE by using an Excel VBA ActiveX controller. The following is a basic example.

 

Sub Main()

    Dim studio As Object
    Set studio = CreateObject("CSTStudio.Application") 'OLE 객체 연결 명령
    
    Dim ems As Object 'ems object 명령
    Set ems = studio.NewEMS
    
    ' 저장경로 + 저장파일
    ems.SaveAs "저장경로 + 저장파일", False
        
    ' Set Solver Type
    Dim setSolver As String
    setSolver = "ChangeSolverType ""LF Frequency Domain"""
    
    ems.AddToHistory "change solver type", setSolver
    
    ' Set Units : 2nd Method
    Dim path As String
    Dim fname As String
    path = ActiveWorkbook.path 'script가 있는 path를 가져오는 명령
   
    
    Dim tmp As Range 'history를 작성하기 위한 tmp 변수 지정
    Set tmp = Sheet1.Range("B2")
    
    ems.AddToHistory "define units", tmp
    
    ems.SaveAs "저장경로+저장파일", True
    
    ems.Quit
    studio.Quit

End Sub

 

 

 

728x90
반응형

댓글