ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
JHJosh Hixon07/05/2019

Okay, I have fought with this long enough, time to ask the genius of the forum community.

I have a macro that saves a drawing as a PDF into our PDM professional vault, problem is that it is grayed out because it is a local version. I can right click and add to the vault, but I would like for this macro to not only add it to the vault but to also check it in. I have poured over the PDM API help files and am still so lost. I find the way the help files code things very difficult to understand. My visual basic skill is growing but pretty beginner level still.

This is what I have but my very last line seems to be an issue I can't figure out what to do with it.

Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc2

Dim swDraw As SldWorks.DrawingDoc

Dim Filepath As String

Dim FileName As String

Dim boolstatus As Boolean

Dim longstatus As Long, longwarnings As Long

Dim vault1 As New EdmVault5

Sub main()

Set swApp = Application.SldWorks

Set swModel = swApp.ActiveDoc

' Check to see if a drawing file is loaded.

If (swModel Is Nothing) Or (swModel.GetType <> swDocDRAWING) Then

swApp.SendMsgToUser ("Only for use with Drawings")

Exit Sub

End If

' vault login

vault1.LoginAuto "SPECTRUM", 0

' Set filepath and add tag on file name using custom properties

Set swDraw = swModel

Dim Rev As String

Dim folder As String

Rev = swModel.CustomInfo("Revision")

Filepath = "C:\SPECTRUM\Spectrum\Shop Pdf Access\"

If Right(Filepath, 1) <> "\" Then

Filepath = Filepath & "\"

End If

FileName = Left(swDraw.GetTitle, Len(swDraw.GetTitle) - 10)

file = Filepath + FileName + " - " + Rev + ".PDF"

swDraw.SaveAs (file)

'add and checkin to vault

vault1.RootFolder.AddFile 0, Filepath, file, 0

End Sub