I have been working on this macro to save certain sheets out of a drawing based on sheet name as a dxf file. I have the macro working, but it requires a msgbox to work. I have tried all that I know to make it work without but cannot.
Te company that I work for would like to incorporate it into our PDM workflow at approval and this will not work with the msgbox.
any thoughts?
Thanks
shawn
********************************************************************************************************************************************************************************************************
Dim swApp As Object
Dim boolstatus As Boolean
Dim bool As Boolean
Dim longstatus As Long
Dim longwarnings As Long
Dim Drawing As Object
Dim swCustProp As CustomPropertyManager
Dim swModelDocExt As ModelDocExtension
Dim so As String
Dim sheets As Variant
Dim sheet_name As String
Dim i As Long
Dim so_n As Double
Dim val As String
Dim valout As String
Dim sofolder As Double
Dim sofolder_t As String
Dim sofolder2 As Double
Dim sofolder2_t As String
Dim Drawingname As String
Dim path As String
Dim filename As String
Sub main()
Set swApp = _
Application.SldWorks
Set Drawing = swApp.ActiveDoc
Set swModelDocExt = Drawing.Extension
Call get_Properties
Call set_path
Call get_sheets
Call save_cycle
End
End Sub
Sub msg()
Dim iRet As Integer
Dim strTitle As String
Drawingname = path + sheets(i) + ".dxf"
strTitle = "File Name" ' Dialog's Title
'Display MessageBox
iRet = MsgBox(Drawingname, vbSystemModal, strTitle)
End Sub
Sub time()
Dim PauseTime, Start
PauseTime = 1 ' Set duration in seconds
Start = timer ' Set start time.
Do While timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
End Sub
Sub save()
longstatus = Drawing.SaveAs3(Drawingname, 0, 0)
End Sub
Sub save_cycle()
Dim temp As String
For i = 0 To UBound(sheets)
sheet_name = sheets(i)
temp = Left(sheet_name, 1)
If temp <> "S" And temp <> "s" Then
Drawing.ActivateSheet (sheets(i))
'Call msg
Call time
Call save
End If
Next i
End Sub
Sub get_sheets()
sheets = Drawing.GetSheetNames ' Get names of sheets and store in single array
End Sub
Sub set_path()
so_n = valout
so = so_n
so = Left(so, 3)
so_n = so
sofolder = so_n * 1000 + 1
sofolder_t = sofolder
sofolder2 = (so_n + 1) * 1000
sofolder2_t = sofolder2
so = valout
path = "C:\\_EPDM_Vault1\\Shop Orders\\" + sofolder_t + "-" + sofolder2_t + "\\" + so + "\\" + "drawings\\dxf\\"
End Sub
Sub get_Properties()
boolstatus = swApp.SetUserPreferenceIntegerValue(swUserPreferenceIntegerValue_e.swDxfMultiSheetOption, swDxfMultisheet_e.swDxfActiveSheetOnly)
Set swCustProp = swModelDocExt.CustomPropertyManager("")
bool = swCustProp.Get4("shop order number", False, val, valout)
End Sub
SolidworksApi macros