17 Replies Latest reply on Apr 17, 2014 3:30 AM by Simon Turner

    [VBA] How to create a file?

    Alex Reds

      Hi, I am trying to write a macro and one of the actions that I want my macro does is create a .txt file that has the same name of my solidwork.SLDPRT.

      For example, if my SLDPRT file is named "abc.SLDPRT" I want that my macro creates a txt file and names it "abc.txt"...

       

      I wrote these lines, but the txt file isn't create. What's wrong?

       

       

          ...

          tFilename = swModel.GetPathName

          sFilename = Left(tFilename, Len(tFilename) - 7)

          Set mFSO = CreateObject("Scripting.FileSystemObject")

          Set mOutTxt = mFSO.CreateTextFile("C:\Users\Desktop\" & sFilename & ".txt", True)

          ...

       

       

      Thank you very much