Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reading value from a field

Status
Not open for further replies.

tractng

MIS
Sep 26, 2005
21
US
Guys,


Below is my current code. The code writes a value to a field in the
current active document.


Instead of writing the value to the current field (assuming the field
value is there already), how can I make it read that field's value
from the active document and write the value to a file that is not
currently active (sitting in the background within the program which is
located in c:\temp). Btw, the API unique name is the same on both
pages.


Public Sub Test3()
' Declare the Application object
Dim oApplication As Inventor.Application


' Obtain the Inventor Application object.
' This assumes Inventor is already running.
Set oApplication = GetObject(, "Inventor.Application")


' Set a reference to the active document.
' This assumes a document is open.
Dim oDoc As Document
Set oDoc = oApplication.ActiveDocument


' Obtain the PropertySets collection object
Dim oPropsets As PropertySets
Set oPropsets = oDoc.PropertySets


' Get a reference to the "Date Checked" property.
Dim oProp As Property
Dim PartNum As String


Set oProp =
oPropsets.Item("{32853F0F-3444-11d1-9E93-0060B03C1CA6}").ItemByPropId(kStoc­kNumberDesignTrackingProperties)


' Define a Date variable with the desired date.


PartNum = "9836-scoobie1"


' Assign the date to the property.
oProp.Value = PartNum


End Sub


Thanks in advance,
Tony


 
Hi Tony,

Here's some generic code for reading (& outputting) field codes and values in a document:

Sub ListFields()
Dim oFld As Field
If ActiveDocument.Fields.Count > 0 Then
For Each oFld In ActiveDocument.Fields
With Selection
.EndKey Unit:=wdStory
.InsertAfter vbCrLf
.EndKey Unit:=wdStory
.TypeText Text:="{" & oFld.Code & "}, " & oFld.Result
End With
Next oFld
End If
End Sub

Cheers
 
Macropod,

Thanks man!! Something that I need. Its been a long time I wrote some VB(A). I was thinking of doing a For Loop and read the records of it. I will try it tomorrow.

TOny
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top