Board index » delphi » WordDocument1.Save not saving to desired directory.

WordDocument1.Save not saving to desired directory.

(WordDocument1.Save not saving to desired directory.)

Hi, here is one more problem, probably easy for all of you ...

When I try to save WordDocument1 which has been filled with data
(WordDocument1.Sentences.Last.InsertAfter...)

Using: WordDocument1.SaveAs(FileName); then it happnes that my file is
beeing saved at c:\My Documents. Problem is that FileName looks like
'd:\Work\My other documents\Test.DOC'.

-> So why this is not saved at disk d:\Work\My Other Documents ?
-> Or how to save it to some other location that is not 'default document
folder' ?

 

Re:WordDocument1.Save not saving to desired directory.


From what I have seen .save saves the document back to where it was opened
from. If you want to save it to a new location then use .SaveAs.

I also mistrust MS Word to save to the write directory so I make sure by
changing the default directory ( I have had problems in the past with
certain versions of Word so I prefer to be OTT). Here is a simple solution

   OldPath := WordApplication.Options.Get_DefaultFilePath(wdDocumentsPath);
   {presuming all temp files start with document and that I do not save my
files that way}
   if (uppercase(copy(WordDocument.Name,1,8)) = 'DOCUMENT')   then
   begin
      TheFileName:= InputBox('New Template', 'Enter the file name',
WordDocument.Name+'.doc');
      WordApplication.Options.Set_DefaultFilePath(wdDocumentsPath,MyDir);
      TheFile := TheFileName;
      WordDocument.SaveAs(TheFile);
   end
      try
         WordDocument.Save;
      except
         MessageDlg('No save was carried out',mtWarning,[mbOk],0);
         WordApplication.WindowState := wdWindowStateMinimize;
      end;
   end;
   WordApplication.Options.Set_DefaultFilePath(wdDocumentsPath,OldPath);

Quote
"Petar Banicevic" <peta...@usa.net> wrote in message

news:8a5uf1$70g7@bornews.borland.com...
Quote
> (WordDocument1.Save not saving to desired directory.)

> Hi, here is one more problem, probably easy for all of you ...

> When I try to save WordDocument1 which has been filled with data
> (WordDocument1.Sentences.Last.InsertAfter...)

> Using: WordDocument1.SaveAs(FileName); then it happnes that my file is
> beeing saved at c:\My Documents. Problem is that FileName looks like
> 'd:\Work\My other documents\Test.DOC'.

> -> So why this is not saved at disk d:\Work\My Other Documents ?
> -> Or how to save it to some other location that is not 'default document
> folder' ?

Other Threads