Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Using MS Access as a front end for SW 1

Status
Not open for further replies.

tmalinski

Mechanical
Oct 14, 2002
424
Is it possible to create/open a new solidworks file and populate some of it's properties using MSAccess as a front end? I'm pretty sure opening or creating the file is simple enough, but what about it's properties.
I have a MSAccess guru at my disposal he just needs some basic direction.
Thanks,
Tom

Tom Malinski
Dell Prec 670, Xeon 3.8,2GB Ram, Nvidia Quadra FX 3450/4000 SDI
SWorks Pro & PDMWorks 2007 SP3.0
 
Replies continue below

Recommended for you

The properties are there from the template file, but the values put into them would need to be updated for each file.
Example:

DetailNo
ToolNo
Description

My Access database automatically bumps these values and generates the next sequential file name also!

Tom Malinski
Dell Prec 670, Xeon 3.8,2GB Ram, Nvidia Quadra FX 3450/4000 SDI
SWorks Pro & PDMWorks 2007 SP3.0
 
No problem. You can open a file, add or edit properties and save as a new file. Here is an example for your Access guru. Remind him/her to enable the SolidWorks type libraries in the Access VBA references. This example opens a part file, adds a description custom property and saves as a new file. The custom properties do not need to be already created in the original SolidWorks file.

Code:
Private Sub cmdButton_Click()

Dim swApp               As SldWorks.SldWorks
Dim swDoc               As SldWorks.ModelDoc2
Dim lErrors             As Long
Dim lWarnings           As Long
Dim BoolStatus          As Boolean
Dim strTemplateName     As String
Dim strDocName          As String
    
Set swApp = CreateObject("SldWorks.Application")
strTemplateName = "C:\\MyPart.sldprt"
Set swDoc = swApp.OpenDoc6(strTemplateName,swDocPART, swOpenDocOptions_Silent, "", lErrors,  lWarnings)
BoolStatus = swDoc.AddCustomInfo3("", "Description", swCustomInfoText, "My Description")
    
strDocName = "C:\\MyNewPart.sldprt"
BoolStatus = swDoc.SaveAs4(strDocName, swSaveAsCurrentVersion, swSaveAsOptions_Copy, lErrors, lWarnings)
swApp.CloseDoc (strTemplateName)
   
Set swDoc = Nothing
Set swApp = Nothing

End Sub
 
Stoker, thanks for the help. I'm sure this will give us a kick start.

a star for you...

tom

Tom Malinski
Dell Prec 670, Xeon 3.8,2GB Ram, Nvidia Quadra FX 3450/4000 SDI
SWorks Pro & PDMWorks 2007 SP3.0
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor