×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Close Current Document Macro
2

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

RE: Close Current Document Macro

(OP)
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

RE: Close Current Document Macro

2
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.

RE: Close Current Document Macro

Quote:


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
 

RE: Close Current Document Macro

(OP)
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.

RE: Close Current Document Macro

Bsj,

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

&

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources