pyroclasm
Computer
- May 17, 2005
- 24
Hey Gurus,
I have a form with two TextBoxes (txtTitle and txtType), plus one Button (btnNext).
What I am trying to do is...
1. Form popsup, give info on the active opened Doc.
2. User presses Next Button and the Next document that is open becomes active and it's info repopulates the Textboxes.
What is my code missing? Please help.
Robert
Private Sub btnNext_Click()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Set swApp = Application.SldWorks
Set swModel = swApp.GetFirstDocument
While Not swModel Is Nothing
Set swModel = swModel.GetNext
swDocUpdate txtTitle, txtType
Wend
End Sub
'--------------------
Private Sub UserForm_initialize()
swDocUpdate txtTitle, txtType
End Sub
'--------------------
Function swDocUpdate(strTxtTitle As Object, strTxtType As Object)
Dim swApp As SldWorks.SldWorks
Dim swModelDoc As SldWorks.ModelDoc2
Dim swDocTitle As String
Dim swDocType As String
Dim swDocGetNext As String
Dim strTypePRT As String
Dim strTypeASM As String
Dim strTypeDRW As String
Set swApp = Application.SldWorks
Set swModelDoc = swApp.ActiveDoc
strTypePRT = "Part (SLDPRT)" 'Part = 1
strTypeASM = "Assembly (SLDASM)" 'Assembly = 2
strTypeDRW = "Drawing (SLDDRW)" 'Drawing = 3
'Get Component Information
swDocTitle = swModelDoc.GetTitle
swDocType = swModelDoc.GetType
If swDocType = 1 Then
strTxtType.Text = strTypePRT
ElseIf swDocType = 2 Then
strTxtType.Text = strTypeASM
Else
strTxtType.Text = strTypeDRW
End If
strTxtTitle.Text = swDocTitle
End Function
I have a form with two TextBoxes (txtTitle and txtType), plus one Button (btnNext).
What I am trying to do is...
1. Form popsup, give info on the active opened Doc.
2. User presses Next Button and the Next document that is open becomes active and it's info repopulates the Textboxes.
What is my code missing? Please help.
Robert
Private Sub btnNext_Click()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Set swApp = Application.SldWorks
Set swModel = swApp.GetFirstDocument
While Not swModel Is Nothing
Set swModel = swModel.GetNext
swDocUpdate txtTitle, txtType
Wend
End Sub
'--------------------
Private Sub UserForm_initialize()
swDocUpdate txtTitle, txtType
End Sub
'--------------------
Function swDocUpdate(strTxtTitle As Object, strTxtType As Object)
Dim swApp As SldWorks.SldWorks
Dim swModelDoc As SldWorks.ModelDoc2
Dim swDocTitle As String
Dim swDocType As String
Dim swDocGetNext As String
Dim strTypePRT As String
Dim strTypeASM As String
Dim strTypeDRW As String
Set swApp = Application.SldWorks
Set swModelDoc = swApp.ActiveDoc
strTypePRT = "Part (SLDPRT)" 'Part = 1
strTypeASM = "Assembly (SLDASM)" 'Assembly = 2
strTypeDRW = "Drawing (SLDDRW)" 'Drawing = 3
'Get Component Information
swDocTitle = swModelDoc.GetTitle
swDocType = swModelDoc.GetType
If swDocType = 1 Then
strTxtType.Text = strTypePRT
ElseIf swDocType = 2 Then
strTxtType.Text = strTypeASM
Else
strTxtType.Text = strTypeDRW
End If
strTxtTitle.Text = swDocTitle
End Function