need code example

need code example

Anonymous
Not applicable
425 Views
8 Replies
Message 1 of 9

need code example

Anonymous
Not applicable
I need to create a macro that fires on save and removes all "hard typing" in the parts list. I haven't used vba for years and am very rusty. Can anyone get me started with code examples?
0 Likes
426 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable
>removes all "hard typing" in the parts list

do you mean "Static" values (the blue values) in a drawing parts list? If so, I couldn't find anything in the VBA API to control whether a PartsListCell is static.
0 Likes
Message 3 of 9

Anonymous
Not applicable
Maybe this is what he is looking for???

Sub StaticValue()

Dim oDrawDoc As DrawingDocument
Dim oSheet As Sheet
Dim oPL As PartsList
Dim oRow As PartsListRow
Dim i As Integer

Set oDrawDoc = ThisApplication.ActiveDocument
Set oSheet = oDrawDoc.ActiveSheet
Set oPL = oSheet.PartsLists.Item(1)
For Each oRow In oPL.PartsListRows
For i = 1 To oRow.Count
If oRow.Item(i).Static = True Then
MsgBox "Static value found! (" & oRow.Item(i).Value & ")",
vbInformation
End If
Next i
Next oRow

End Sub


--
T. Ham
CAD Automation & Systems Administrator
CDS Engineering BV

HP xw4300 Workstation
Dual Pentium XEON 3.6 Ghz
4 GB SDRAM
NVIDIA QUADRO FX 3450/4000 SDI (Driver = 8.4.2.6)
250 GB SEAGATE SATA Hard Disc
3Com Gigabit NIC

Windows XP Professional SP2
Autodesk Inventor Series 10 SP3a
--
0 Likes
Message 4 of 9

Anonymous
Not applicable
This is fine for identifying static values, but what I need is to revert back to the value from the part model using code.
0 Likes
Message 5 of 9

Anonymous
Not applicable
Are you afraid of editing code?

--
T. Ham
CAD Automation & Systems Administrator
CDS Engineering BV

HP xw4300 Workstation
Dual Pentium XEON 3.6 Ghz
4 GB SDRAM
NVIDIA QUADRO FX 3450/4000 SDI (Driver = 8.4.2.6)
250 GB SEAGATE SATA Hard Disc
3Com Gigabit NIC

Windows XP Professional SP2
Autodesk Inventor Series 10 SP3a
--
0 Likes
Message 6 of 9

Anonymous
Not applicable
 
0 Likes
Message 7 of 9

Anonymous
Not applicable
No, just ignorant. I was trying this:

Dim oCell as PartsListCell
Set oCell.Static = True (this got me an "Improper use of property" message).

My apologies for trying to learn from others who might know better.
0 Likes
Message 8 of 9

Anonymous
Not applicable
you don't Set a property.

Set and Let have important (different) meanings in VBA. Use Set for objects, use Let for properties.

Change the code to:

Let oCell.Static = True
0 Likes
Message 9 of 9

Anonymous
Not applicable
Thanks. Thats a great explanation!
0 Likes