weird behavior with attempting to use document

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
-2147467259 (80004005)
Method 'Value' of object 'property' failed
I get this error message sometimes when I run a macro I created. This macro is started by an iLogic rule at file creation (through the drawing template) and on the first drawing I create each time I open inventor it works fine. Then I get the error every time I try to create a new document. Except it works fine after the first time, regardless of whether I manually run the rule or run the macro directly from a button. I have no clue what is going on with it and why it is happening.
Here is the rule that runs at startup:
'iLogicForm.Show("Title block")
InventorVb.RunMacro("ApplicationProject", "Module1", "EditProperties")
Here is the macro that calls the form:
Sub EditProperties()
On Error GoTo 2
2:
Do While ThisApplication.ActiveDocument.NeedsMigrating
Loop
Titleblockfrm.Tardigrade
End Sub
Here is the code for the form:
Option Explicit Private Title1 As Property Private Title2 As Property Private Title3 As Property Private Material As Property Private Finish As Property Private Createdby As Property Private Checkedby As Property Private Drawingnumber As Property Private Partnumber As Property Private Scalel As Property Private Scaler As Property Dim m_DrawDoc As DrawingDocument Private buffer As Property Private errors As Integer Dim oCustomPropSet As PropertySet ' Private Sub CancelButton_Click() hide End Sub Private Sub ApplyButton_Click() 'On Error Resume Next If Me.Createdbox.Text <> Createdby.Value Then Createdby.Value = Me.Createdbox.Text 'MsgBox ("createdby") If Newdrawingbox.Value Then Set buffer = oCustomPropSet.Item("Drawn Date") buffer.Value = DateTime.Now End If End If If (Not Checkedbox.Text = "") And (Not Checkedbox.Text = Checkedby.Value) Then buffer.Value = DateTime.Now End If If Me.Checkedbox.Text <> Checkedby.Value Then Checkedby.Value = Me.Checkedbox.Text 'MsgBox ("checkedby") End If If Me.Title1box.Text <> Title1.Value Then Title1.Value = Me.Title1box.Text End If If Me.Title2box.Text <> Title2.Value Then Title2.Value = Me.Title2box.Text End If If Me.Title3box.Text <> Title3.Value Then Title3.Value = Me.Title3box.Text End If If Me.DrawingNumberBox.Text <> Drawingnumber.Value Then Drawingnumber.Value = Me.DrawingNumberBox.Text End If If Me.Partnumberbox.Text <> Partnumber.Value Then Partnumber.Value = Me.Partnumberbox.Text End If If Me.Materialbox.Text <> Material.Value Then Material.Value = Me.Materialbox.Text End If If Me.Finishbox.Text <> Finish.Value Then Finish.Value = Me.Finishbox.Text End If If Me.lspin.Value <> Scalel.Value Then Scalel.Value = lspin.Value End If If Me.Rspin.Value <> Scaler.Value Then Scaler.Value = Rspin.Value End If ThisApplication.ActiveDocument.Update End Sub Private Sub OkayButton_Click() ApplyButton_Click CancelButton_Click End Sub Private Sub Lscale_Change() On Error GoTo l lspin.Value = CLng(Lscale.Value) l: If Not Rscale.Value = "" Then Lscale.Value = lspin.Value End If End Sub Private Sub Rscale_Change() On Error GoTo r Rspin.Value = CLng(Rscale.Value) r: If Not Rscale.Value = "" Then Rscale.Value = Rspin.Value End If End Sub Private Sub Rspin_Change() Rscale.Value = Rspin.Value End Sub Private Sub Lspin_Change() Lscale.Value = lspin.Value End Sub Sub UserForm_Initialize() On Error GoTo 0 While ThisApplication.ActiveDocument Is Nothing Wend Set m_DrawDoc = ThisApplication.ActiveDocument On Error Resume Next errors = 0 Set oCustomPropSet = m_DrawDoc.PropertySets.Item("Inventor User Defined Properties") Set Title1 = oCustomPropSet.Item("Title 1") If Err Then ' The property doesn't exist, so create it. Call oCustomPropSet.Add("", "Title 1") errors = errors + 1 Call MsgBox("error") Err.Clear End If Me.Title1box.Text = Title1.Value If Err Then End If Set Title2 = oCustomPropSet.Item("Title 2") If Err Then ' The property doesn't exist, so create it. Call oCustomPropSet.Add("", "Title 2") errors = errors + 1 Call MsgBox("error") Err.Clear End If Me.Title2box.Text = Title2.Value Set Title3 = oCustomPropSet.Item("Title 3") If Err Then ' The property doesn't exist, so create it. Call oCustomPropSet.Add("", "Title 3") errors = errors + 1 Call MsgBox("error") Err.Clear End If Me.Title3box.Text = Title3.Value Set Checkedby = oCustomPropSet.Item("Checked By") If Err Then ' The property doesn't exist, so create it. Call oCustomPropSet.Add("", "Checked By") errors = errors + 1 Call MsgBox("error") Err.Clear End If Me.Checkedbox.Text = Checkedby.Value Set Createdby = oCustomPropSet.Item("Drawn By") If Err Then ' The property doesn't exist, so create it. Call oCustomPropSet.Add("", "Drawn By") errors = errors + 1 Call MsgBox("error") Err.Clear End If Me.Createdbox.Text = Createdby.Value Set Drawingnumber = oCustomPropSet.Item("Drawing Number") If Err Then ' The property doesn't exist, so create it. Call oCustomPropSet.Add("", "Drawing Number") errors = errors + 1 Call MsgBox("error") Err.Clear End If Me.DrawingNumberBox.Text = Drawingnumber.Value Set Material = oCustomPropSet.Item("Material") If Err Then ' The property doesn't exist, so create it. Call oCustomPropSet.Add("", "Material") errors = errors + 1 Call MsgBox("error") Err.Clear End If Me.Materialbox.Text = Material.Value Set Finish = oCustomPropSet.Item("Finish") If Err Then ' The property doesn't exist, so create it. Call oCustomPropSet.Add("", "Finish") errors = errors + 1 Call MsgBox("error") Err.Clear End If Me.Finishbox.Text = Finish.Value Set Partnumber = oCustomPropSet.Item("Part Number") If Err Then ' The property doesn't exist, so create it. Call oCustomPropSet.Add("", "Part Number") errors = errors + 1 Call MsgBox("error") Err.Clear End If Me.Partnumberbox.Text = Partnumber.Value Set Partnumber = oCustomPropSet.Item("Part Number") If Err Then ' The property doesn't exist, so create it. Call oCustomPropSet.Add("", "Part Number") errors = errors + 1 Call MsgBox("error") Err.Clear End If Me.Partnumberbox.Text = Partnumber.Value Set Scalel = oCustomPropSet.Item("Lscale") If Err Then ' The property doesn't exist, so create it. Call oCustomPropSet.Add(1, "Lscale") errors = errors + 1 Call MsgBox("error") Err.Clear End If Me.Lscale.Text = Scalel.Value Me.lspin.Value = Scalel.Value Set Scaler = oCustomPropSet.Item("Rscale") If Err Then ' The property doesn't exist, so create it. Call oCustomPropSet.Add(1, "Rscale") errors = errors + 1 Call MsgBox("error") Err.Clear End If Me.Rscale.Text = Scaler.Value Me.Rspin.Value = Scaler.Value Set buffer = oCustomPropSet.Item("Drawn Date") If Err Then ' The property doesn't exist, so create it. Call oCustomPropSet.Add(DateSerial(0, 0, 0), "Drawn Date") errors = errors + 1 Call MsgBox("error") Err.Clear End If If buffer.Expression = "" Then Newdrawingbox.Value = True Else Newdrawingbox.Value = False End If Set buffer = oCustomPropSet.Item("Checked Date") If Err Then ' The property doesn't exist, so create it. Call oCustomPropSet.Add(DateSerial(0, 0, 0), "Checked Date") errors = errors + 1 Call MsgBox("error") Err.Clear End If On Error GoTo 0 'Me.Show End Sub Sub Tardigrade() Show End Sub