Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Close Current Document Macro 2

Status
Not open for further replies.

bsj0526

Mechanical
Jan 5, 2008
40
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
 
Replies continue below

Recommended for you

Here is the code with the first few lines. The Set part = activedoc line does that, right?


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
 
I'll have to try it at work, but I think it's something like:
Code:
swApp.CloseDoc(Part.GetPathName)

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:
sFileTitle = Part.GetPathName

Then your's might work.
 
I'm just a hack though. :)

Then what does that make me?

-Dustin
Professional Engineer
Certified SolidWorks Professional
Certified COSMOSWorks Designer Specialist
Certified SolidWorks Advanced Sheet Metal Specialist
 
brengine, I think adding the definition is what I needed. Ill continue to give it heck and see if it works. Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor