Home > Software engineering >  For help! I want to open the SolidWorks part file in vb, could you tell me how to do?
For help! I want to open the SolidWorks part file in vb, could you tell me how to do?

Time:09-18

Specific idea is to set up a button, and then the pop-up dialog, find want to open the file, open it again? Thank you for the great god

CodePudding user response:

If just pop up open file dialog box, the with common dialog box controls,
If you choose to file, and open the specific file, you need to structure the code,

CodePudding user response:

Thank you thank you thank you

CodePudding user response:

Could you tell me what do you know the subsequent code
Private Sub open_Click ()
CommonDialog2. CancelError=True 'set "CancelError" to True
On Error GoTo ErrHandler 'set the sign
CommonDialog2.=cdlOFNHideReadOnly 'Flags set filters
CommonDialog2. Filter="All Files (*. *) | *. * | Text Files" & amp; "(*.txt) | *. TXT | Batch Files (*. Bat) | *. Bat" 'specify a default filter
CommonDialog2. FilterIndex=2 'show "open" dialog
CommonDialog2. ShowOpen 'according to the selected file extensions
Text2=Mid (CommonDialog2 filename, InStr (CommonDialog2 filename, "") + 1)
The Set swApp=CreateObject (" SldWorks. Application ")
The Set Part=swApp. ActiveDoc
SwApp. Visible (True)
The Set Part=swApp. Competing OpenDoc (Text2 swDocPART)
The Exit Sub
ErrHandler: 'the user presses the "cancel" button
The Exit Sub
End Sub
My code is such, but just open the SolidWorks program

CodePudding user response:

I made of Delphi, but in the end is just started the Solidworks program, file does not open, if anyone knows, explain?
Swapp:=GetOrCreateObject (' SldWorks. Application);//use function GetOrCreate create or obtain SolidWorks object
Swapp. Visible:=true;//to create Solidworks object visible
Part:=swapp. Competing OpenDoc (' E: \ \ T typical weld type single v. LDPRT ');

CodePudding user response:

reference 4 floor qq_41643732 response:
I made of Delphi, but in the end is just started the Solidworks program, file does not open, if anyone knows, explain?
Swapp:=GetOrCreateObject (' SldWorks. Application);//use function GetOrCreate create or obtain SolidWorks object
Swapp. Visible:=true;//to create Solidworks object visible
Part:=swapp. Competing OpenDoc (' E: \ \ T typical weld type single v. LDPRT ');


Despise upstairs dug grave...


If you see "started the Solidworks program", that means the code until swapp. Visible:=true; The performance is "normal",
File did not open "and", that is:
Part:=swapp. Competing OpenDoc (' E: \ \ T typical weld type single v. LDPRT ');
The "results" is not in line with expectations,
Has the potential of two aspects:
1. Solidworks COM interface has a problem, but the possibility is very small, so a "big project", in the spirit shall can never do this small thing!) ,
2. You passed to the competing OpenDoc () function of the parameters is wrong!
This is the biggest possible, you should check the document, this function should be how to use,
If there are other parameters for "are you omit" caused "the document has been opened, but didn't show up '(such as the default' background open)", so you don't think the document open...
  •  Tags:  
  • API
  • Related