vba - SolidWorks 2013 Macro - String manipulation? -


solidworks uses vba macros, different excel vba (which i'm accustomed to). made difficult (and quite possibly impossible) manipulate strings in sw. i've tried using left() function , mid() function, can not figure out how make work. need do, save .dxf file , name title, without sheet name. sheet name causing problem , i'm trying cut out. can use

part.gettitle 

to string of title which, example like

pa0000 - sheet1 

and want

pa0000 

sometimes length different, i've tried using

left(part.gettitle,instr(part.gettitle, " ")-1) 

but gives type mismatch error. doing wrong? that's left macro cut out " - sheet1".

i have made changes code @ help.solidworks.com; should work you. change folders needed.

dim swapp object  dim part object dim boolstatus boolean dim longstatus long, longwarnings long 'http://help.solidworks.com/2012/english/api/sldworksapi/save_file_as_pdf_example_vb.htm sub main()     dim swapp                       sldworks.sldworks     dim swmodel                     sldworks.drawingdoc     dim swpart                      sldworks.partdoc     dim bret                        boolean     dim mypath                      string     dim myfolder                    string     dim longstatus                  long     dim filename                    string     set swapp = application.sldworks      set swmodel = swapp.activedoc      myfolder = "c:\temp" ' change temp drive since curdir write protected.     myfile = left(swmodel.getpathname, instrrev(swmodel.getpathname, ".") - 1)     myfile = right(myfile, len(myfile) - instrrev(myfile, "\"))     mypath = left(swmodel.getpathname, instrrev(swmodel.getpathname, "\") - 1)     mypath = right(mypath, len(mypath) - instrrev(mypath, "\"))      debug.print "filename = " & myfile     debug.print "file = " & swmodel.getpathname     debug.print "folder = " & mypath     debug.print "current folder = " & curdir$     debug.print (myfolder & "\" & myfile & ".dxf")     filename = myfolder & "\" & myfile & ".dxf"     longstatus = swmodel.saveas3(filename, 0, 0)     ' pdf generation     ' longstatus = swmodel.saveas3(myfolder & "\" & myfile & ".pdf", 0, 0)  end sub 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -