It seems that the Document Manager API can not be used in VBA.
Am I right or I am missing something?
AFAIK, it can not be used with VBA
Yes, it can certainly be used with VBA, although you need a license key string. This can be obtained from firstname.lastname@example.org. However, it's for internal use only. You can't distribute outside your company.
Edit: Email method is old!. Now you get at this link:
Thanks for sharing the info that it can be used with VBA also.
FYI, I'll be doing a break-out session at SWW 2016 focused on the Document Manager. If you'll be at SWW, please come! Currently scheduled for Monday at 2:45pm. I'm planning on covering these topics...
That should be super useful!
On a slightly related note, do you have any info on the history etc of document manager API? I'm particularly curious:
1. Why you need a license key
2. Why access was changed to open for one release of SW ('08 maybe? I forget)
3. Why it was locked back down
4. Why it's now locked down even further to where you have to specify the extent of functionality
I'm sure there are reasons, but I've never really seen them explained. With no explanation it just seems like stupid hoops to jump through to get access to useful tools.
Hopefully these will help...
I can't find the documentation now (it may have even been expunged), but for 2007 the requirement for the key was removed. Document manger API was wide open, which I thought was a good thing. Then it snapped back shut on one of the service packs.
I guess I don't really see what's being protected if you give away keys to whoever asks. You may be able to see who can come in the door, but how they got there, what they're bringing, and what they do once they get in are still wide open, right?
Hello Nirantar Vidyarthee,
I use this routine in SolidWorks 2016 to get custom property without load files.
Dim swapp As SldWorks.SldWorksDim f As SwDMClassFactorySet swapp = Application.SldWorksDim p As stdole.StdPicture
If UserForm1.TextBox2.Text = "File non Esistente" Then Exit FunctionIf Disegno.Value = True Then Exit FunctionIf Dwg.Value = True Then Exit Function
Set f = New SwDMClassFactory
Dim swCfg As SwDMConfiguration14Dim swCfgMgr As SwDMConfigurationMgrDim vCfgNameArr As VariantDim vCfgName As Variant
Dim a As SwDMApplicationSet a = f.GetApplication("***********Your serial***********")
Dim d As ISwDMDocument3Dim d2 As ISwDMDocument17Dim e As SwDmDocumentOpenErrorDim path As String
path = swapp.GetExecutablePath'Debug.Print UserForm1.TextBox2.Text'File_con_Path = UserForm1.TextBox2.Text'Debug.Print "File_con_Path: "; File_con_Path
Set d = a.GetDocument(File_con_Path, 1, True, e)Set d2 = a.GetDocument(File_con_Path, 1, True, e)
On Error GoTo Whoa
Set swCfgMgr = d2.ConfigurationManager
Dim Descrizione As String
vCfgNameArr = swCfgMgr.GetConfigurationNames
Set swCfg = swCfgMgr.GetConfigurationByName(vCfgNameArr(0)) Description = swCfg.GetCustomProperty2("Description", swDmCustomInfoText) Autor = swCfg.GetCustomProperty2("Autor", swDmCustomInfoText) Date = swCfg.GetCustomProperty2("Date", swDmCustomInfoText)
Debug.Print "Description: "; Description Debug.Print "Autor: "; Autor Debug.Print "Date: "; Date
Retrieving data ...