1 Reply Latest reply on Apr 4, 2012 1:42 PM by Michael Jeffries

    open a part file using a button in a userform in VB.Net

    tyty tyty

      I am trying to open a part file using a button in a userform in VB.Net

       

      I want Creating a SolidWorks Add-in and open file from this program

        • Re: open a part file using a button in a userform in VB.Net
          Michael Jeffries

          The quick and (dirty) way is to use a simple process start function.  I use this method all the time for launching excel / pdf documents from a listbox.  Be warned, this will launch the program with the system default for that file extension (which should be solidworks most likely).

           

           

           

          Imports System.Diagnostics

           

          'Declaration(s)

          Dim startinfo As New ProcessStartInfo

           

           

          Function LaunchFile(byval FilePath as string)     'Filepath is the full filename with extension, ex: c:\temp\tube.sldprt

               startinfo.FileName = FilePath

               startinfo.Arguments = False

               Process.Start(startinfo)

               return 0

          end function

           

           

          'To launch the file:

           

          sub ButtonPressed(byval sender as system.object, byval e as system.eventargs) handles button1.click

           

               Launchfile("c:\temp\tube.sldprt")

           

          end sub

           

           

          EDIT:  Once you've created the program and compiled it, you then point to the .DLL of your program with the macro editor in solidworks.  If you want to implement this across a broader board, i am unsure how the add-in manager works through the PDM administrator as I am just a lowly design engineer and doesnt have access to the vault