SOLIDWORKS Task Schedular我试了,根本动不了,自己也倒腾了个宏,功能是工程图转换成PDF和DWG文件,操作是,工具---》宏----》新建----》把下面的代码复制进去----》存到硬盘某个位置----》,调用的时候是,工具----》宏---》运行,当然也可以自定义到SW的工具栏上,宏文件源代码如下需要的拿去,:; ~ R/ a5 u3 `$ M6 `$ n Dim swApp As Object 8 L) R; i- x. X/ ADim Part As Object , g2 }8 E! z$ z. RDim boolstatus As Boolean6 w9 ]) y" H# h- n& R Dim longstatus As Long, longwarnings As Long ( g( v- ~ w/ YDim PathStr As String9 Y% b" T. R& `$ D7 v Dim FName(500) As String, FNum As Long # T& ?) h. q. M8 v( j ' I" {. F2 D. Q9 ?Sub main() % ^3 |" ~" B4 k8 I4 |Dim i As Long- C6 X1 w- Z( ^- H0 A Dim PathStr0 As String, PathStr1 As String % i/ S/ O9 A; X8 I* M$ T) D, LDim PathStr2 As String, PathStr3 As String, PathStr4 As String, PahtStr5 As String9 g# U3 k) w2 W/ M0 o4 { Dim L As Long, L1 As Long' R, W& F1 I0 @% M4 |- a* G PathStr = InputBox("请输入需要转的工程图所在位置")/ u0 d5 u" w* d: k9 j- L4 ]( S Call Showfilelist(PathStr) * H- S: y+ k8 \3 w# YSet swApp = Application.SldWorks . B, K; A4 ~# Y, I9 e 1 y, Z2 x$ X4 n4 G2 o; h& ~For i = 0 To FNum - 1 1 M8 B* N/ f7 J$ t U3 ?5 _ kPathStr0 = PathStr & "\" & FName(i) $ D8 A- A. t2 g3 Q4 wSet Part = swApp.OpenDoc6(PathStr0, 3, 0, "", longstatus, longwarnings)/ ?8 S- h2 E. P5 t/ m* E L = Len(PathStr0)" O( i/ T! N. K' o; j; |# K$ l5 J PathStr1 = Left(PathStr0, L - 7) & ".DWG" ! C; K* `" g3 U0 p8 [" KPathStr2 = Left(PathStr0, L - 7) & ".PDF" % R# O2 D9 N% A$ j7 s- O4 w& O1 Zlongstatus = Part.SaveAs3(PathStr1, 0, 0)2 E/ \4 K _2 R4 X# L longstatus = Part.SaveAs3(PathStr2, 0, 0)$ n, t4 }# _% ] t t. x6 `
: D' Z3 c* w; f' O8 d6 QSet Part = Nothing 4 S. h6 G" j% v- k $ i1 ~8 W) P0 ^9 bL1 = Len(FName(i)) " i% I2 I8 g' F: aPathStr3 = Left(FName(i), L1 - 7) & " - 图纸1" % }5 G I( O1 F3 [8 [# DPathStr4 = Left(FName(i), L1 - 7) & " - 图纸2"0 R! B: F# y7 b3 S. o! W, [) @ PathStr5 = Left(FName(i), L1 - 7) & " - 图纸3"9 G' S) w/ h$ W o( G2 @5 X4 I% ? # J/ L( k% g; S" _4 R$ M swApp.CloseDoc PathStr3 7 [1 q& U0 _, k! t; ~swApp.CloseDoc PathStr4 / |& r o. I3 k) gswApp.CloseDoc PathStr5 6 k9 _ Q+ E' O5 l& | 9 o6 Z4 |2 ^/ r qNext i' T; g5 Z4 [3 L1 k1 y* Z - Q9 Z. w0 }5 P( h: R End Sub " T0 ` Q) Z( a: F& R @" A" t1 Z6 l3 `$ P, q% x1 f5 r* P Private Sub Showfilelist(folderspec As String) & ]3 J2 }$ s6 ?0 W' oDim fs, f, f1, fc, s 3 t' X8 b5 t; N! GSet fs = CreateObject("Scripting.FileSystemObject") + I1 p6 l( S cSet f = fs.GetFolder(folderspec)8 K$ c6 V- \. k5 T! V Set fc = f.Files% t2 e8 i/ W% L5 N FNum = 0 '清零 * R4 ~* k2 |* `( T/ S" S# P" C% pFor Each f1 In fc3 J$ o8 F) K$ c8 f: L5 U If InStr(f1.Name, "SLDDRW") > 0 Then + M& r8 f n. U6 eFName(FNum) = f1.Name2 @" j1 _4 N" D FNum = FNum + 12 Z! E% W/ u+ c5 O( a/ {% L End If2 W! U5 W2 {( E' _, _ Next 7 ~ A% A g u) C1 bEnd Sub ! s: Q* ~. j9 s* f9 E |