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!

Calling the second file when both files are opened

Status
Not open for further replies.

tractng

MIS
Sep 26, 2005
21
US
Guys,

Lets say the Drawing.idw and Part1.ipt files are already open by the users. The .Drawing.idw will be the "active document". How do I call the Part1.ipt file so it will be the file that I want to copy the information too?


Instead of hard-coding.

Set oDoc1 = oApplication.Documents.ItemByName("C:\twd\Part1.ipt")

Remember both files are already opened.

Thanks,
Tony
------------------- Below is my code -----------------

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")
'Set oDoc1 = oApplication.Documents.ItemByName(sLocation)

' 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 String
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

'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
On Error Resume Next
Set oPropsets3 = oDoc1.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
oPropsets3.Add vManager, "Color", 20

If Err Then
Set oPropsets3 = oDoc1.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
oPropsets3.Add vManager, "Color", 20

End If

Set oPropsets3 = oDoc1.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
oPropsets3.Add vManager, "Color", 20

' writing onto the Custom tab field from 'Company' field
On Error Resume Next
Set oPropsets4 = oDoc1.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
oPropsets4.Add vCompany, "Compound #", 30

If Err Then
Set oPropsets4 = oDoc1.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
oPropsets4.Add vCompany, "Compound #", 30
End If


'writing onto the Custom tab field from 'Author' field

On Error Resume Next
Set oPropsets2 = oDoc1.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
oPropsets2.Add vAuthor, "Durometer", 40

If Err Then
Set oPropsets2 = oDoc1.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
oPropsets2.Add vAuthor, "Durometer", 40
End If

'===============================================================
Dim oPdoc As PartDocument

Set oPdoc = oDoc1

'Dim oComp As ComponentDefinition
Set oComp = oPdoc.ComponentDefinition

Dim sTemp As String
Dim oMat As Material

On Error Resume Next

Set oMat = oPdoc.Materials(vSubject)

If Err Then

MsgBox "Material doesn't match! Must select manually from the Physical tab", vbInformation, ""

Else

oPdoc.ComponentDefinition.Material = oMat

End If


End Sub


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top