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 non active document

Status
Not open for further replies.

tractng

MIS
Sep 26, 2005
21
US
Guys,

How do I call a non active document (file) and making it an active document.

Current, I am reading doc1 as being active. Once I am done, I like to call another document(doc2) and make it active.

Any codes?

Thanks in advance.
Tony
 
Hi tractng,

Code:
Documents("doc2").Activate
will do it (assuming doc2 is open) but you don't need to activate a document to work on it with code.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Tony,

I need your help. I want to be able to read the current active file (field in the property page) and write that value to a non-active file (field in the property page). Both files are open by the same program (Inventor).

My current codes allow me to read the fields. I just cannot able to combine the codes to write it to a non-active file while reading the active file.

If it is not possible, should I store the variables and call the file name to make it an active document and write to it.

Thanks in advance.
Tony

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

Dim oDoc1 as Document
Set oDoc1 =?????

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

Dim oPropsets1 As PropertySets
Set oPropsets1 = oDoc.PropertySets

' Get a reference to the "Description" property.
Dim oProp As Property
Dim oProp1 as Property

Dim sRead As String

'==========================================================
'reading the current active file (value from property page)
'project tab - field 5

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

sRead = oProp.Value

'==========================================================


'==========================================================
'writing to a non-active file, non-active file is in the background opened by the same program
'file location is C:\TWD.DRAWING1.IDW

'Set oProp1 = oPropsets.Item("{32853F0F-3444-11d1-9E93-0060B03C1CA6}").ItemByPropId(kDescriptionDesignTrackingProperties)

oProp.Value = sRead

'==========================================================


End Sub
 
Hi Tony,

I'm afraid I haven't a clue what Inventor is, let alone how to work with it. I can only guess based on what I know of other applications.

Does it have a Documents collection? Can you get a reference to a document via something like ..

oApplication.Documents("DocumentName")

If not, I'm not sure what to suggest.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Tony,

It does have a document collection with activate, close, update, etc.

I am stuck. Help?

tractng
 
Hi Tony,

If it has a Documents collection, can you not do
Code:
Set oDoc1 = oApplication.Documents("[i]DocumentName[/i]")
or
Code:
oApplication.Documents("[i]DocumentName[/i]").Activate
at the appropriate point?

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Tony,

This is what the vendor suggested.

Use oApplication.Documents.Item or oApplication.Documents.ItemByName to obtain the second document of interest. The ItemByName property accepts the
full file name of the document that is open.

I was able to use:

Set oDoc1 = oApplication1.Documents.ItemByName("C:\TWD\Part1.ipt")

But if I used the following, I would get an error regarding type mismatch.

Set oDoc = oApplication.Documents.Item("Part1.ipt")


Any idea? If I can, I rather just use the file name only since the file is opened already.

Tony
 
Hi Tony,

I think it's really down to some trial and error on your part. As I don't have access to the object model I can only guess.

How many documents are open? Can you use ...Item(2), or can you loop through all open documents to find what you want. Do your document objects have Name, Path, or Fullname properties?

Or, if you know it's open, how is that? Is it because you have opened it in code? If so can you save a global reference to it when you open it?

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Tony,

I will try each one individually. There will be two files opened by the user. The documents have full file.

I just want to make sure the file that i am updating is opened within the software.

Thanks,
Tractng
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top