RC2003
Mechanical
- Feb 4, 2003
- 5
I need help with the macro I have created to simply the task of entering custom properties into the title block of a drawing. Presently the macro consists of only one custom property "Drawn By".
When I run the macro a dialog box pops up and allows me to enter data into the field, click the "ok" command button and the custom properties of the drawing is populated.
When I run the macro a second time the field in the dialog box is empty, but the drawing still contains the custom prop.
Problem
1. I want the field content to be displayed if it has already been filled in.
2. If I modify the field on the second running of the macro and click "ok" the drawing needs to update.
Please don't tell me to look at someone’s web site to solve the problem. I have scoured the web and spent a week trying to figure out the code from other macros.
Here's the Code
Const swCustomInfoUnknow = 0
Const swCustomInfoText = 30
Const SwCustomInfoDate = 64
Const swCustomInfoNumber = 3
Const swCustomInfoYesOrNo = 11
Private Sub UserForm1()
Dim swApp As Object
Dim Part As Object
Dim Gtol As Object
Dim Retval As Object
Dim sDrawn As String
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
sDrawn = Part.CustomInfo2("", "Drawn By"
Part.AddCustomInfo "Drawn", "Text", ""
Part.FileSummaryInfo
End Sub
Private Sub cmd_OK_Click()
Set swApp = CreateObject("SldWorks.Application"
Set Part = swApp.ActiveDoc
Retval = Part.AddCustomInfo3("", "Drawn By", swCustomInfoText, TxtDrawn.text)
Unload Me
End Sub
Private Sub cmd_cancel_Click()
Unload Me
End Sub
***
The userform has a label "Drawn By", textbox (Name is "drawn" and to command buttons. "Ok and Cancel"
When I run the macro a dialog box pops up and allows me to enter data into the field, click the "ok" command button and the custom properties of the drawing is populated.
When I run the macro a second time the field in the dialog box is empty, but the drawing still contains the custom prop.
Problem
1. I want the field content to be displayed if it has already been filled in.
2. If I modify the field on the second running of the macro and click "ok" the drawing needs to update.
Please don't tell me to look at someone’s web site to solve the problem. I have scoured the web and spent a week trying to figure out the code from other macros.
Here's the Code
Const swCustomInfoUnknow = 0
Const swCustomInfoText = 30
Const SwCustomInfoDate = 64
Const swCustomInfoNumber = 3
Const swCustomInfoYesOrNo = 11
Private Sub UserForm1()
Dim swApp As Object
Dim Part As Object
Dim Gtol As Object
Dim Retval As Object
Dim sDrawn As String
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
sDrawn = Part.CustomInfo2("", "Drawn By"
Part.AddCustomInfo "Drawn", "Text", ""
Part.FileSummaryInfo
End Sub
Private Sub cmd_OK_Click()
Set swApp = CreateObject("SldWorks.Application"
Set Part = swApp.ActiveDoc
Retval = Part.AddCustomInfo3("", "Drawn By", swCustomInfoText, TxtDrawn.text)
Unload Me
End Sub
Private Sub cmd_cancel_Click()
Unload Me
End Sub
***
The userform has a label "Drawn By", textbox (Name is "drawn" and to command buttons. "Ok and Cancel"