Hi,

Excel and PowerPoint have a SaveCopyAs method
(Workbook/Presentation).

Word does not have such a function.
Does anyone know how so simulate such a function in Word ?

My best idea is the code below.

The below code compares the memory image of the active document
with the file it is associated with.
The compare results are placed in a new file.
Any changes in the resulting new file are accepted
and the results written to the temp file.

Thanks
Michael




Public Sub Test()

Dim TempName As String
Dim OrigName As String

TempName = "C:\temp\" & ActiveDocument.Name
OrigName = ActiveDocument.FullName

ActiveDocument.Compare
Name:=OrigName, CompareTarget:=wdCompareTargetNew
'the new document is now active
If ActiveDocument.Revisions.Count >= 1 Then _
ActiveDocument.Revisions.AcceptAll
ActiveDocument.SaveAs FileName:=TempName
ActiveDocument.Close

End Sub

Re: Word SaveCopyAs by Doug

Doug
Tue Jan 27 08:04:41 CST 2004

Hi Michael,

Use

Dim SourceFile, DestinationFile
ActiveDocument.Save
SourceFile = ActiveDocument.Name ' Define source file name.
DestinationFile = "C:\Temp\" & SourceFile ' Define target file name.
ActiveDocument.Close
FileCopy SourceFile, DestinationFile ' Copy source to target
Documents.Open SourceFile

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
"Michael Sundermann" <> wrote in message
news:j0pc10dplk44f3a0rqbj5fbj4mc16rv426@4ax.com...
> Hi,
>
> Excel and PowerPoint have a SaveCopyAs method
> (Workbook/Presentation).
>
> Word does not have such a function.
> Does anyone know how so simulate such a function in Word ?
>
> My best idea is the code below.
>
> The below code compares the memory image of the active document
> with the file it is associated with.
> The compare results are placed in a new file.
> Any changes in the resulting new file are accepted
> and the results written to the temp file.
>
> Thanks
> Michael
>
>
>
>
> Public Sub Test()
>
> Dim TempName As String
> Dim OrigName As String
>
> TempName = "C:\temp\" & ActiveDocument.Name
> OrigName = ActiveDocument.FullName
>
> ActiveDocument.Compare
> Name:=OrigName, CompareTarget:=wdCompareTargetNew
> 'the new document is now active
> If ActiveDocument.Revisions.Count >= 1 Then _
> ActiveDocument.Revisions.AcceptAll
> ActiveDocument.SaveAs FileName:=TempName
> ActiveDocument.Close
>
> End Sub
>
>
>
>



Re: Word SaveCopyAs by Michael

Michael
Wed Jan 28 02:48:48 CST 2004

On Wed, 28 Jan 2004 00:04:41 +1000, "Doug Robbins - Word MVP - DELETE
UPPERCASE CHARACTERS FROM EMAIL ADDRESS"
<dkr@mOSTvALUABLEpROFESSIONALs.org> wrote:

Thanks for your solution,
but it does not simulate SaveCopyAs.

The important thing is that SaveCopyAs
saves the active document to a different file
_without_ saving the active document.



Re: Word SaveCopyAs by JGM

JGM
Wed Jan 28 10:42:12 CST 2004

Hi Michael,

> The important thing is that SaveCopyAs
> saves the active document to a different file
> _without_ saving the active document.

Sorry, but how is that different from the SaveAs method? Unless io totally
missed your point, it seems to me that Word already offers what you need.

"Save as" does exactly that: save the active document as a new document
without saving the changes in that active document.

Try it:
Create a new document;
Type "Test 1";
Save it, call it "Test 1.doc";
Now, hit ENTER;
Type "Test 2";
From the "File" menu, select "Save as" (not save);
Call it "Test 2.doc";
Close Word;
Open "Test 1.doc";
See that it contains only "Test 1";
Open "Test 2.doc";
See that it contains "Test1"¶ "Test 2";

Isn't this what you are looking for?

Cheers!
--
_______________________________________
Jean-Guy Marcil
jmarcil@sympatico.ca

"Michael Sundermann" <SPAMmail@MichaelSundermann.deMAPS> a écrit dans le
message de news: qnte10t63tc6uegqb8gcsnmnqghn7d7r7t@4ax.com...
> On Wed, 28 Jan 2004 00:04:41 +1000, "Doug Robbins - Word MVP - DELETE
> UPPERCASE CHARACTERS FROM EMAIL ADDRESS"
> <dkr@mOSTvALUABLEpROFESSIONALs.org> wrote:
>
> Thanks for your solution,
> but it does not simulate SaveCopyAs.
>
> The important thing is that SaveCopyAs
> saves the active document to a different file
> _without_ saving the active document.
>
>



Re: Word SaveCopyAs by Doug

Doug
Wed Jan 28 15:00:27 CST 2004

Then use

Dim SourceFile
SourceFile = ActiveDocument.FullName ' Define source file name.
ActiveDocument.SaveAs
ActiveDocument.Close
Documents.Open SourceFile


--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
"Michael Sundermann" <> wrote in message
news:qnte10t63tc6uegqb8gcsnmnqghn7d7r7t@4ax.com...
> On Wed, 28 Jan 2004 00:04:41 +1000, "Doug Robbins - Word MVP - DELETE
> UPPERCASE CHARACTERS FROM EMAIL ADDRESS"
> <dkr@mOSTvALUABLEpROFESSIONALs.org> wrote:
>
> Thanks for your solution,
> but it does not simulate SaveCopyAs.
>
> The important thing is that SaveCopyAs
> saves the active document to a different file
> _without_ saving the active document.
>
>



Re: Word SaveCopyAs by Michael

Michael
Thu Jan 29 04:43:01 CST 2004

> Sorry, but how is that different from the SaveAs method? Unless io totally
>missed your point, it seems to me that Word already offers what you need.

Using the SaveAs(file) method changes the active document to "file".

Excel and Powerpoint have both methods: SaveAs and SaveCopyAs.
With SaveCopyAs you can save the active document to a file
and nothing else happens.


Re: Word SaveCopyAs by Michael

Michael
Thu Jan 29 04:49:17 CST 2004


>Dim SourceFile
>SourceFile = ActiveDocument.FullName ' Define source file name.
>ActiveDocument.SaveAs
>ActiveDocument.Close
>Documents.Open SourceFile

Thanks for this solution.
This solution has 2 disadvantages:
1.
The user gets a "flash", because Word closes and opens
the document.
I want to use such a function in an Add-On,
probably many users thinks my AddOn has an error
if they got such a flash.

2.
The solution only works if the Document was saved before.
If not, Sourcename is like "Document" and Word reports
an error. But this could be repaired:

If Sourcename does not exists
create a tremporay name
endif



At the moment I only care about the flash.
But with my solution I also get such a flash.