Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to open Ansys APDL using Excel VBA

Status
Not open for further replies.

Pattanshetti

Mechanical
Feb 9, 2015
21
0
0
IN
Hello,

I am trying to create a macro in excel vba whose function is to open ansys apdl, read some files is sequence(/input) and generate the respective output files. I have already created macro for reading input in ansys but I am not able find the codes for opening ansys apdl through excel vba. Please help me in this regard.

Thank You.
 
Replies continue below

Recommended for you

Hi there,

I've been making excel sheets with hundreds of runs for parametric models. Here's how I do it:
1, make a batch that executes your analysis (can be written by VBA)
2, run the batch from VBA

for point 1:
create a batch file (.bat) that runs ANSYS with parameters that will make it: run in batch, run in certain directory, execute in batch mode.
You can use The ANSYS Mechanical APDL Product Launcher to help to put the command together. Switch simulation environment to ANSYS Batch and in options choose Tools->Display Command Line

Code:
cd /D D:\temp"C:\Program Files\ANSYS Inc\v140\ansys\bin\winx64\ANSYS140.exe" -j job -b -p prfnls -dir "D:\temp\" -i input.txt -o output.log

for point 2:
execute the batch file in Excel VBA
Code:
    Dim wsh As Object
    Set wsh = VBA.CreateObject("WScript.Shell")

    wsh.Run sWorkdir & strBatchFileName, 0, True

It is possible to set it up in Excel such that the sheet does not freeze (or maybe it's already in the wsh.Run arguments).

I hope this helps.

Pavel
 
Status
Not open for further replies.
Back
Top