Macro to "SaveAs" before Saving...

T

Tobias

Hi

Simple question, but tricky for me......

I've created a small macro to save a backup automatically on another drive
before saving the document:

Private Sub Document_BeforeDocumentSave(ByVal doc As IVDocument)
Dim pageObj As Visio.Page
Set pageObj = ThisDocument.Pages(1)
ThisDocument.SaveAs "Z:\Backup1.vsd"
End Sub

But it changes the pointer in the file to Z, not D where the master is and
it is only saving it on the z, not d - so how can I change it back to D
after the backup is created and save it normally ?

2. question - what is the number in the ThisDocument.Pages(1) refering to ?
It seems to save all pages anyway ?

Thanks

Tobias
 
A

al edlund

this from developing visio solutions

To change the name, drive, or path of a document,
use the SaveAs method to save the document under a different name or to a different
drive or path.

Regarding the question you asked relative to your code on pagObj, all you have done
is instantiated the pagObj with the first page of the document. It has nothing to do with
your save as code.
 
G

GMorris

The code is not even using the Page object at all, just getting an instance
of it.
In fact, unless you plan on saving only certain pages, don't even use it.

Now, in order to make this work, all you have to do is do another SaveAs to
the original file and drive:path after the backup. That will set the pointer
back
to where you want it. Using "ThisDocument.Path & ThisDocument.Name"
as the second SaveAs argument should do the trick!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top