Close Current Document Macro
Close Current Document Macro
(OP)
Hello,
I am working on a macro with some common commands that i can check off and press a button and it applies all the commands with a check. One command I am having trouble with is the close current document. I have tried a couple of different variations that I found by searching, but the only one I can get to work (sometimes) is below. I say sometimes, because it will work once, then it quits for a while. Does anyone know the correct way to do this?
End If
'Close
If CheckBox4 = True Then
swApp.CloseDoc sFileTitle
Else
End If
End Sub
I am working on a macro with some common commands that i can check off and press a button and it applies all the commands with a check. One command I am having trouble with is the close current document. I have tried a couple of different variations that I found by searching, but the only one I can get to work (sometimes) is below. I say sometimes, because it will work once, then it quits for a while. Does anyone know the correct way to do this?
End If
'Close
If CheckBox4 = True Then
swApp.CloseDoc sFileTitle
Else
End If
End Sub






RE: Close Current Document Macro
Matt Lorono
Lorono's SolidWorks Resources & SolidWorks Legion
&
RE: Close Current Document Macro
Private Sub CommandButton15_Click()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
'Close
If CheckBox4 = True Then
swApp.CloseDoc sFileTitle
Else
End If
End Sub
RE: Close Current Document Macro
Matt Lorono
Lorono's SolidWorks Resources & SolidWorks Legion
&
RE: Close Current Document Macro
CODE
In the snippit of code above...I don't see you ever assigning a value to sFileTitle...maybe that's the problem with it? If somewhere else you had a line like:
CODE
Then your's might work.
RE: Close Current Document Macro
Then what does that make me?
-Dustin
Professional Engineer
Certified SolidWorks Professional
Certified COSMOSWorks Designer Specialist
Certified SolidWorks Advanced Sheet Metal Specialist
RE: Close Current Document Macro
RE: Close Current Document Macro
That's kinda what I was working towards finding out when I asked to see your code, to make sure my hunch was correct...but brengine just jumped right in! :) Star
Matt Lorono
Lorono's SolidWorks Resources & SolidWorks Legion
&