J'ai essayé d'utiliser la macro de .PL (http://www.lynkoa.com/tutos/solidworks-creer-tous-les-pdf-pour-un-dossier-0) qui permet de convertir tous les plans d'un dossier en PDF mais j'ai un problème lorsque je la lance.
J'ai le message "Erreur de compilation: Sub ou Function non définie" à la ligne Path = BrowseFolder("Select a Path/Folder")
J'ai un peu fouillé sur le forum et j'ai vu que d'autres personnes avaient eu le même problème mais je n'ai pas trouvé de solution.
A moins que je ne fasse une erreur, il manque un morceau à la macro. BrowseFolder est une sous fonction donc à mon sens ça manque d'où le message d'erreur.
@d.roger, j'ai toujours la même erreur après avoir ajouté "Microsoft Shell Controls And Automation". J'ai comparé et j'ai les mêmes références que sur ta capture d'écran d'activées.
J'ai juste changer la façon d'ouvrir la fenêtre de sélection de dosssier. Pas testé le ocmportement global.
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc
Dim sFileName As String
Dim vFileName As String
Dim Path As String
Dim nPath As String
Dim nErrors As Long
Dim nWarnings As Long
Dim swDraw As SldWorks.DrawingDoc
Dim swCustProp As CustomPropertyManager
Dim swView As SldWorks.View
Dim ConfigName As String
Dim i As Long
Dim valOut1 As String
Dim valOut2 As String
Dim resolvedValOut1 As String
Dim resolvedValOut2 As String
Dim PartNo As String
Dim nFileName As String
Dim swDocs As Variant
Dim PDFpath As String
Dim currpath As String
Dim PartNoDes As String
Dim objShell As Shell
Dim objFolder As Folder
Sub main()
Set swApp = Application.SldWorks
Dim swExportPDFData As SldWorks.ExportPdfData
Set swExportPDFData = swApp.GetExportFileData(1)
swExportPDFData.ViewPdfAfterSaving = False
Set objShell = New Shell
Set objFolder = objShell.BrowseForFolder(0, "Example", 0, 0)
If (Not objFolder Is Nothing) Then
Path = objFolder.Self.Path
Path = Path + "\"
PDFpath = Path & "PDF"
If Dir(PDFpath, vbDirectory) = "" Then MkDir PDFpath
sFileName = Dir(Path & "*.slddrw")
sFileName = Dir(Path & "*.slddrw")
Do Until sFileName = ""
Set swModel = swApp.OpenDoc6(Path + sFileName, swDocDRAWING, swOpenDocOptions_Silent, "", nErrors, nWarnings)
Set swModel = swApp.ActiveDoc
Set swDraw = swApp.ActiveDoc
Set swView = swDraw.GetFirstView
Set swView = swView.GetNextView
Set swModel = swView.ReferencedDocument
PDFpath = currpath & "PDF"
If Dir(PDFpath, vbDirectory) = "" Then MkDir PDFpath
If swModel.GetType = swDocPART Then
PartNoDes = Mid(swDraw.GetPathName, InStrRev(swDraw.GetPathName, "\") + 1)
PartNoDes = Right(PartNoDes, Len(PartNoDes) - 14)
PartNoDes = Left(PartNoDes, Len(PartNoDes) - 7)
PartNo = Mid(swModel.GetPathName, InStrRev(swModel.GetPathName, "\") + 1)
PartNo = Left(PartNo, Len(PartNo) - 7)
Set swCustProp = swModel.Extension.CustomPropertyManager(swView.ReferencedConfiguration)
ConfigName = swView.ReferencedConfiguration
swCustProp.Get2 "Description", valOut1, resolvedValOut1
swCustProp.Get2 "Revision", valOut2, resolvedValOut2
nFileName = PDFpath & "\" & PartNo & "-" & ConfigName & "-" & resolvedValOut2 & " " & PartNoDes
swDraw.SaveAs3 nFileName & ".PDF", 0, 0
ElseIf swModel.GetType = swDocASSEMBLY Then
PartNoDes = Mid(swDraw.GetPathName, InStrRev(swDraw.GetPathName, "\") + 1)
PartNoDes = Right(PartNoDes, Len(PartNoDes) - 11)
PartNoDes = Left(PartNoDes, Len(PartNoDes) - 7)
PartNo = Mid(swModel.GetPathName, InStrRev(swModel.GetPathName, "\") + 1)
PartNo = Left(PartNo, Len(PartNo) - 7)
Set swCustProp = swModel.Extension.CustomPropertyManager("")
swCustProp.Get2 "Description", valOut1, resolvedValOut1
swCustProp.Get2 "Revision", valOut2, resolvedValOut2
nFileName = PDFpath & "\" & PartNo & "-" & resolvedValOut2 & " " & PartNoDes
swDraw.SaveAs3 nFileName & ".PDF", 0, 0
End If
swApp.QuitDoc swDraw.GetPathName
Set swDraw = Nothing
Set swModel = Nothing
sFileName = Dir
Loop
End If
Set objFolder = Nothing
Set objShell = Nothing
MsgBox "All Done"
End Sub