SW MACRO to open a file/folder

Hello

We use a Macro at the end of the design to generate:
1 part on the outside
1 STEP
1 PDF 3D

I would like to have the option to open or not the folder (or files) that have just been generated

By scratching a little on the internet,
I pulled it out of my hat

'Macro execution message
Msg=" MACRO DONE: " & vbCrLf & vbCrLf & " Do you want to open the generated files folder?" 
Style = vbYesNo
Title = " SOLIDWORKS "
Help = "  "
Ctxt = "  "
Answer = MsgBox(Msg, Style, Title, Help, Ctxt)

If Response = vbYes Then
Set swDoc = swApp.OpenDoc(sFilesPath, swDocumentTypes_e.swDocNONE)
End If

I think I have problems with the If Answer / Set swDoc
But I can't find the solution

Thank you in advance for your help :slight_smile:
And good WE :wink:

Hello
I haven't tested more than that but I think the problem comes from swDocumentTypes_e.swDocNONE and the use of OpenDoc which has been obsolete for at least a good ten years (even if still supported it lacks options that can be useful for imports).
I think I have already answered another topic on opening step files via macro, the 3D SW PDF does not know how to open it, you have to use Adobe, there is only the part that can work in the current macro.
On the other hand, I will remove Help and Ctxt, if they are empty I might as well not put them and I will not bother with variables if they are not used elsewhere (msg hard in MsgBox as well as the different parameters).
As it stands, the code snippet tries to open the file and not the folder in which the file is located.

1 Like