Hello everyone,
I'm looking for a piece of macro coding, to close 1 drawing, which I just consulted, without saving the changes.
My tests my driving with the learning mode:
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Sub main()
Set swApp = _
Application.SldWorks
Set Part = swApp.ActiveDoc
Set Part = Nothing
swApp.CloseDoc "MEP 01 - Sheet2"
End Sub
Unfortunately this macro is only suitable for 1 given plan file
I would like the macro to close the active MEP without saving it
Kind regards
new SW
I think this should help you, it works on my macro
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set SelMgr = Part.SelectionManager
Part.ViewZoomtofit2
Set Part = Nothing
swApp.CloseDoc "Drawing1 - Sheet1"
swApp.ActiveDoc.ActiveView.FrameLeft = 0
swApp.ActiveDoc.ActiveView.FrameTop = 0
swApp.ActiveDoc.ActiveView.FrameState = 1
Set Part = swApp.ActivateDoc2("Part1", False, longstatus)
swApp.ActiveDoc.ActiveView.FrameState = 1
End Sub
Thank you
your macro is like mine it is just suitable for 1 file, for me: "MEP 01 - Sheet2"
I'm looking for it to work for all MEPs
Hello,
Here's a quick macro, you can remove the drawing check if you don't need it.
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
'We check if there is indeed an open document
If Not swModel Is Nothing Then
'We check if it's a drawing
If swModel.GetType = swDocDRAWING Then
swApp.CloseDoc swModel.GetTitle
Else
MsgBox "This macro only works on drawings", vbCritical + vbOKOnly
End If
Else
MsgBox "Please open a document", vbExclamation + vbOKOnly
End If
End Sub
Bravo KVuilleumier
Your macro works like thunder,
I'm waiting for another answer but yours is very good
Regards newSW
I'm glad my macro helped you.
Therefore, would it be possible to put my answer (the one that contains the macro) as the best answer? :) Thank you.
OK KVuilleumier
you can tell me how they do to get you in the best answer
By the way I also posted 1 question about 1 macro that will reopen the file that your macro has closed,
Kind regards
New SW
At the bottom right you wrote "Mark as best answer", just click on it.