Hi all
I am currently modifying an existing macro so that it adapts to my constraints.
The existing macro allows conversion of SLDDRW file to PDF and DXF with the choice of source and destination folder and change the name following the revision of the plan.
Brief...
In my case I would like to convert to PDF and DWG without worrying about the revision but that we can have a choice (like checkbox between PDF and DWG.
I managed to make some changes (like removing everything related to the revision) and modify DXF to DWG and insert my chexboxes on the Userfrom.
But on the other hand, for the coding of the checkboxes I have a problem (knowing that I don't have a lot of bottle in VBA, I tried something but hey).
If you have an idea?
Thank you:)
Here's some of the code:
Private Sub FiltreBox_Change()
StartConvert.Enabled = False
TextSource.Caption = "Validate source directory"
TextSource.ForeColor = RGB(255, 0, 0)
OkSource = False
CheckSource.Enabled = True
End Sub
Private Sub SourceBox_Change()
StartConvert.Enabled = False
TextSource.Caption = "Validate source directory"
TextSource.ForeColor = RGB(255, 0, 0)
OkSource = False
CheckSource.Enabled = True
End Sub
Private Sub CheckBox1_Click()
End Sub
Private Sub CheckBox2_Click()
End Sub
Private Sub StartConvert_Click()
Set swApp = Application.SldWorks
TimeDebut = Timer
DestinationFileNumber = 0
FileName = Dir(PathDepart & FilterBox.Value & ". SLDDRW")
' Begins the loop
Do While FileName<> ""
DestinationFileNumber = DestinationFileNumber + 1
Advance.Caption = "Processing File" & DestinationFileNumber &" / " & FileSource Number & " : " & FileName
SaveDir.Repaint
FileNameWithoutExtension = Left(FileName, Len(FileName) - 7)
Opening the file
Set Part = swApp.OpenDoc6(PathDepart & FileName, 3, 0, "", longstatus, longwarnings)
swApp.OpenDoc6 PathDepartir & FileName, 3, 0, "", longstatus, longwarnings
Set Part = swApp.ActivateDoc2(FileName, False, longstatus)
Set swCustPrpMgr = Part.Extension.CustomPropertyManager("")
Creation of the pdf file
If CheckBox1.Value = True Then
Part.Extension.SaveAs PathArrival & FileNameWithoutExtension & ".pdf", 0, 0, Nothing, longstatus, longwarnings
End If
'Creating the dwg file
If CheckBox1.Value = True Then
Part.Extension.SaveAs PathArrivee & FileNameWithoutExtension & ".dwg", 0, 0, Nothing, longstatus, longwarnings
End If
'Closure of the plan
Set Part = Nothing
swApp.CloseDoc FileName
FileName = Dir ' Gets the following entry.
Loop
StartConvert.Enabled = False
TimeFin = Timer
Progress.Caption = "Operation completed." & DestinationFileNumber & " / " & FileSourceNumber&" file(s) processed. Elapsed Time: " & TimeSerial(0, 0, TimeFin - TimeDebut)
End Sub
Private Sub UserForm_Initialize()
OkSource = False
OkSource = False
StartConvert.Enabled = False
FiltreBox.Value = "*"
TextSource.Caption = "Introduce and validate the source directory"
TextSource.ForeColor = RGB(255, 0, 0)
TextDestination.Caption = "Enter and validate the destination directory"
TextDestination.ForeColor = RGB(255, 0, 0)
SourceBox.Value = "Z:\deals"
DestinationBox.Value = "Z:\deals"
Advancement.Caption = ""
End Sub