Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Sub Command1_Click()
If Dir(App.Path & "\公差零件.SLDDRW") = "" Then
Call MsgBox("此文件不存在!", vbExclamation)
Exit Sub
End If
'使用默认程序打开文件
Call ShellExecute(hwnd, "Open", App.Path & "\公差零件.SLDDRW", "", App.Path, 1)
Set DatumTag = Part.InsertDatumTag2()
If Not DatumTag Is Nothing Then
DatumTag.FilledTriangle = 1
DatumTag.Shoulder = 0
Set Annotation = DatumTag.GetAnnotation()
If Not Annotation Is Nothing Then
boolstatus = Annotation.SetPosition(1.067232377125, 0.6552597614075, -3.550623543045E-15)
End If
End If
Dim Note As Object
Dim TextFormat As Object
Set Note = Part.InsertNote("<FONT name=""仿宋_GB2312"" size=20PTS><FONT color=D><FONT name=""Century Gothic"" size=3.5 style=RB effect=RU><FONT style=RI effect=RS>其余")
If Not Note Is Nothing Then
Note.Angle = 0
boolstatus = Note.SetBalloon(0, 0)
Set Annotation = Note.GetAnnotation()
If Not Annotation Is Nothing Then
longstatus = Annotation.SetLeader2(False, 0, True, False, False, False)
boolstatus = Annotation.SetPosition(0.2690534456254, 0.8237577458876, 0)
Set TextFormat = Part.GetUserPreferenceTextFormat(swDetailingNoteTextFormat)
TextFormat.Italic = False
TextFormat.Underline = False
TextFormat.Strikeout = False
TextFormat.Bold = False
TextFormat.Escapement = 0
TextFormat.LineSpacing = 0.001
TextFormat.CharHeight = 0.0035
TextFormat.TypeFaceName = "Century Gothic"
TextFormat.WidthFactor = 1
TextFormat.ObliqueAngle = 0
TextFormat.LineLength = 0
TextFormat.Vertical = False
TextFormat.BackWards = False
TextFormat.UpsideDown = False
TextFormat.CharSpacingFactor = 1
boolstatus = Annotation.SetTextFormat(0, False, TextFormat)
End If
End If
Part.ClearSelection2 True
Part.WindowRedraw
End Sub
作者: blackriver 时间: 2006-6-27 17:43
红色改为以下两句试试:
dim swApp as Application.SldWorks
Set swApp = new Application.SldWorks作者: sherry1860 时间: 2006-6-28 09:38
好象还是不行,试了下,问题改变了,现在是说:用户定义类型未定义,能否再帮我看下啊,谢谢~