Guys,
Instead of hard coding the location of the file, I like to have a dialog box that allows the user to locate the file.
Any code samples or link I can use.
Set oDoc1 = oApplication.Documents.ItemByName("C:\twd\Part1.ipt")
Below is my complete code. I commented things out for testing purposes.
Thanks,
Tony
------------------------------------------------------
Sub Update1()
' 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
Dim oDoc1 As Document
Set oDoc = oApplication.ActiveDocument
Set oDoc1 = oApplication.Documents.ItemByName("C:\twd\Part1.ipt")
' Obtain the PropertySets collection object
'Dim oPropsets As PropertySets
Set oPropSets = oDoc.PropertySets
Set oPropsets1 = oDoc.PropertySets
Set oPropsets2 = oDoc1.PropertySets
Set oPropsets3 = oDoc1.PropertySets
Set oPropsets4 = oDoc1.PropertySets
' Get a reference to the "Description" property.
Dim oProp As Property
Dim oProp1 As Property
Dim oProp2 As Property
Dim oProp3 As Property
Dim vSubject As Variant
Dim vAuthor As Variant
Dim vManager As Variant
Dim vCompany As Variant
'==========================================================
'reading the current active file (value from property page)
'Summary tab
'reading the 'Title' field
vTitle = oPropSets.Item("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}").ItemByPropId(kTitleSummaryInformation).value
'reading the 'Subject' field
'vSubject = oPropsets1.Item("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}").ItemByPropId(kSubjectSummaryInformation).value
'reading the 'Manager' field
vManager = oPropsets1.Item("{D5CDD502-2E9C-101B-9397-08002B2CF9AE}").ItemByPropId(kManagerDocSummaryInformation).value
' here
'reading the 'Company' field
vCompany = oPropsets1.Item("{D5CDD502-2E9C-101B-9397-08002B2CF9AE}").ItemByPropId(kCompanyDocSummaryInformation).value
'reading the 'Author' field
vAuthor = oPropsets1.Item("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}").ItemByPropId(kAuthorSummaryInformation).value
'=====================================================================
'writing to a non-active file,
'non-active file is in the background opened by the same program
'writing the 'Title' field to summary tab
'Set oProp2 = oPropsets2.Item("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}").ItemByPropId(kTitleSummaryInformation)
'oProp2.value = vTitle
'writing onto the Custom tab field from 'Manager' field
'Set oPropsets3 = oDoc1.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
'oPropsets3.Add vManager, "Color", 2
' writing onto the Custom tab field from 'Company' field
'Set oPropsets4 = oDoc1.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
'oPropsets4.Add vCompany, "Compound #", 3
'writing onto the Custom tab field from 'Author' field
'Set oPropsets2 = oDoc1.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
'oPropsets2.Add vAuthor, "Durometer", 4
End Sub
Instead of hard coding the location of the file, I like to have a dialog box that allows the user to locate the file.
Any code samples or link I can use.
Set oDoc1 = oApplication.Documents.ItemByName("C:\twd\Part1.ipt")
Below is my complete code. I commented things out for testing purposes.
Thanks,
Tony
------------------------------------------------------
Sub Update1()
' 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
Dim oDoc1 As Document
Set oDoc = oApplication.ActiveDocument
Set oDoc1 = oApplication.Documents.ItemByName("C:\twd\Part1.ipt")
' Obtain the PropertySets collection object
'Dim oPropsets As PropertySets
Set oPropSets = oDoc.PropertySets
Set oPropsets1 = oDoc.PropertySets
Set oPropsets2 = oDoc1.PropertySets
Set oPropsets3 = oDoc1.PropertySets
Set oPropsets4 = oDoc1.PropertySets
' Get a reference to the "Description" property.
Dim oProp As Property
Dim oProp1 As Property
Dim oProp2 As Property
Dim oProp3 As Property
Dim vSubject As Variant
Dim vAuthor As Variant
Dim vManager As Variant
Dim vCompany As Variant
'==========================================================
'reading the current active file (value from property page)
'Summary tab
'reading the 'Title' field
vTitle = oPropSets.Item("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}").ItemByPropId(kTitleSummaryInformation).value
'reading the 'Subject' field
'vSubject = oPropsets1.Item("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}").ItemByPropId(kSubjectSummaryInformation).value
'reading the 'Manager' field
vManager = oPropsets1.Item("{D5CDD502-2E9C-101B-9397-08002B2CF9AE}").ItemByPropId(kManagerDocSummaryInformation).value
' here
'reading the 'Company' field
vCompany = oPropsets1.Item("{D5CDD502-2E9C-101B-9397-08002B2CF9AE}").ItemByPropId(kCompanyDocSummaryInformation).value
'reading the 'Author' field
vAuthor = oPropsets1.Item("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}").ItemByPropId(kAuthorSummaryInformation).value
'=====================================================================
'writing to a non-active file,
'non-active file is in the background opened by the same program
'writing the 'Title' field to summary tab
'Set oProp2 = oPropsets2.Item("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}").ItemByPropId(kTitleSummaryInformation)
'oProp2.value = vTitle
'writing onto the Custom tab field from 'Manager' field
'Set oPropsets3 = oDoc1.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
'oPropsets3.Add vManager, "Color", 2
' writing onto the Custom tab field from 'Company' field
'Set oPropsets4 = oDoc1.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
'oPropsets4.Add vCompany, "Compound #", 3
'writing onto the Custom tab field from 'Author' field
'Set oPropsets2 = oDoc1.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
'oPropsets2.Add vAuthor, "Durometer", 4
End Sub