hi!

I have a word document. I added 2 Versions into the ActiveDocument. Now as
from the Object Model its Obvious that there are three main methods to do
something with Versions.

1. Open
2. Delete
3. Save

Now if i want to read binary data of Version 1 into some buffer. I'll have
to Open the version. and then get the path of the opened version and after
that read the files data into buffer. But i don't want to Open the Version.
I just want to read the contents of the specific Version without showing the
user that the Version is opened and then closed.

Is there any solution to this problem

Thanks in advance.

Ahmad jalil Qarshi

RE: Can I read the Version into some Buffer without opening the Versi by Phil

Phil
Fri May 06 10:12:03 CDT 2005

When you open the document that you don't want to show the user, set its
Visible property to False:

Set doc = Documents.Open(FileName:="C:\MyFiles\MyDoc.doc", Visible:=False)

By the way, don't forget to close the document when your done.

Re: Can I read the Version into some Buffer without opening the Versi by Ahmad

Ahmad
Fri May 06 10:31:02 CDT 2005

Thanks Phil!

But the problem is that Version Object's Open method doesn't take any
parameter As in the following code and returns a Document Object. so it I
think that it will not work.

Dim VersionDoc as Document = ActiveDocument.Version(1).Open()

Any Other Idea?

Thanks in advance.

Ahmad Jalil Qarshi



"Phil" <Phil@discussions.microsoft.com> wrote in message
news:E62F3168-39B8-4B83-BB9B-7F957729E7B3@microsoft.com...
> When you open the document that you don't want to show the user, set its
> Visible property to False:
>
> Set doc = Documents.Open(FileName:="C:\MyFiles\MyDoc.doc", Visible:=False)
>
> By the way, don't forget to close the document when your done.



RE: Can I read the Version into some Buffer without opening the V by Phil

Phil
Fri May 06 10:36:06 CDT 2005

Sorry, I didn't specifically mention the Version object. But as you
mentioned, the Open method works with the Version object too.

Also, if you run into problems opening a particular version because you
already have that version open, open it with property ReadOnly:=True.

"Phil" wrote:

> When you open the document that you don't want to show the user, set its
> Visible property to False:
>
> Set doc = Documents.Open(FileName:="C:\MyFiles\MyDoc.doc", Visible:=False)
>
> By the way, don't forget to close the document when your done.

Re: Can I read the Version into some Buffer without opening the V by Phil

Phil
Fri May 06 10:48:03 CDT 2005

Ok I see what you mean.

I would try starting a second instance of Word, and seeing if you can open
the document read-only and invisible, while the document is still open in the
other instance. See if it works.

As you probably know it gets a bit trickier because you have to make sure
the second instance actually does close when you think you are closing it.

Re: Can I read the Version into some Buffer without opening the V by Phil

Phil
Fri May 06 11:18:03 CDT 2005

And if that does not work, then replicate what Word does through the
File-Open dialog when you open a document with the 'Open As Copy' option (its
on the Open button drop-down). Then you can definately open a second copy of
a document.

So in your VBA code, copy the original file to a file with a different name
such as 'Copy of ...', open that file with visible = false, and then open the
version you want.

FileCopy syntax:
FileCopy SourceFileName, DestinationFileName


Good luck! I have to go to bed now :-)


"Phil" wrote:

> Ok I see what you mean.
>
> I would try starting a second instance of Word, and seeing if you can open
> the document read-only and invisible, while the document is still open in the
> other instance. See if it works.
>
> As you probably know it gets a bit trickier because you have to make sure
> the second instance actually does close when you think you are closing it.

Re: Can I read the Version into some Buffer without opening the V by Perry

Perry
Sat May 07 06:48:50 CDT 2005

You can't FileCopy() an open file; you'll get the "Access Denied" message.

What you can do to overcome this, is open the source Open() Lock Access
Binary Read.
Look it up in Help files.

Read the content (binary) using Get()
Open a destination file For Binary Access Write and write the byte chunk
using Put()
Note: you'll have to set a buffersize!
Read the Help files.

This technique is utilized for rapid filecopying because of the ability to
buffersize ...
(Note: as stated, this technique will include copying open files)

-------------------------------------
Krgrds.
Perry

System parameters:
POS: WinXP x64
MSO: MSOffice System
DEV: VS7 (dotnet)
-------------------------------------
"Phil" <Phil@discussions.microsoft.com> wrote in message
news:C5E8B7B7-EFDD-4519-BE38-42F2D03286BD@microsoft.com...
> And if that does not work, then replicate what Word does through the
> File-Open dialog when you open a document with the 'Open As Copy' option
> (its
> on the Open button drop-down). Then you can definately open a second copy
> of
> a document.
>
> So in your VBA code, copy the original file to a file with a different
> name
> such as 'Copy of ...', open that file with visible = false, and then open
> the
> version you want.
>
> FileCopy syntax:
> FileCopy SourceFileName, DestinationFileName
>
>
> Good luck! I have to go to bed now :-)
>
>
> "Phil" wrote:
>
>> Ok I see what you mean.
>>
>> I would try starting a second instance of Word, and seeing if you can
>> open
>> the document read-only and invisible, while the document is still open in
>> the
>> other instance. See if it works.
>>
>> As you probably know it gets a bit trickier because you have to make sure
>> the second instance actually does close when you think you are closing
>> it.