Message 1 of 3
Open and Save Method Enigma
Not applicable
02-05-2007
02:12 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
Here's something I can't explain to me while saving a Drawing document.
I've a Bpart.idw copied from Apart.idw document. The Apart.idw and Bpart.idw reference Apart.ipt
Here's the code I 've used first with the .Open Method and Openvisible parameter set to "True". This works fine. Bpart.idw reference Bpart.ipt.
Then I change the Openvisible to "False". In this case Debug.Print function calls show the good result for the .ReplaceReference method. But when opening the Bpart.idw, Apart.ipt is still referenced.
Sub ReplaceReferenceIdw()
Dim oDrwName As String
oDrwName = "c:\Temp\Bpart.idw"
Dim oNewName As String
oNewName = "c:\Temp\Bpart.ipt"
'Open the Drawing document
Dim oDrwDoc As DrawingDocument
Set oDrwDoc = ThisApplication.Documents.Open(oDrwName, False)
' Search for the first referenced document (assuming it is unique)
Dim oDocDescriptor As DocumentDescriptor
Set oDocDescriptor = oDrwDoc.ReferencedDocumentDescriptors.Item(1)
Dim oFileDescriptor As FileDescriptor
Set oFileDescriptor = oDocDescriptor.ReferencedFileDescriptor
Debug.Print oFileDescriptor.FullFileName 'Show referenced document
' Replace referenced document, Update it, Save it and Close it
Call oFileDescriptor.ReplaceReference(oNewName)
Call oDrwDoc.Update
Debug.Print oFileDescriptor.FullFileName 'Show referenced document
Call oDrwDoc.Save
Debug.Print oFileDescriptor.FullFileName 'Show referenced document again
Call oDrwDoc.Close
End Sub
Obviously, there's something I can't understand. Is anyone could explain that to my tired brain.
C.Saint
Here's something I can't explain to me while saving a Drawing document.
I've a Bpart.idw copied from Apart.idw document. The Apart.idw and Bpart.idw reference Apart.ipt
Here's the code I 've used first with the .Open Method and Openvisible parameter set to "True". This works fine. Bpart.idw reference Bpart.ipt.
Then I change the Openvisible to "False". In this case Debug.Print function calls show the good result for the .ReplaceReference method. But when opening the Bpart.idw, Apart.ipt is still referenced.
Sub ReplaceReferenceIdw()
Dim oDrwName As String
oDrwName = "c:\Temp\Bpart.idw"
Dim oNewName As String
oNewName = "c:\Temp\Bpart.ipt"
'Open the Drawing document
Dim oDrwDoc As DrawingDocument
Set oDrwDoc = ThisApplication.Documents.Open(oDrwName, False)
' Search for the first referenced document (assuming it is unique)
Dim oDocDescriptor As DocumentDescriptor
Set oDocDescriptor = oDrwDoc.ReferencedDocumentDescriptors.Item(1)
Dim oFileDescriptor As FileDescriptor
Set oFileDescriptor = oDocDescriptor.ReferencedFileDescriptor
Debug.Print oFileDescriptor.FullFileName 'Show referenced document
' Replace referenced document, Update it, Save it and Close it
Call oFileDescriptor.ReplaceReference(oNewName)
Call oDrwDoc.Update
Debug.Print oFileDescriptor.FullFileName 'Show referenced document
Call oDrwDoc.Save
Debug.Print oFileDescriptor.FullFileName 'Show referenced document again
Call oDrwDoc.Close
End Sub
Obviously, there's something I can't understand. Is anyone could explain that to my tired brain.
C.Saint