Solved

Changes to Word doc by automation won't be saved

Posted on 2006-10-31
5
733 Views
Last Modified: 2008-02-01
The code:

try
  MyDoc := gwd.ActiveDocument;
  MyDoc.CustomDocumentProperties.Add('DillDall', False, 4 {msoPropertyTypeString}, 'Wanker',EmptyParam);
  MyDoc.CustomDocumentProperties.Add('GodkjentAv', False, 4 {msoPropertyTypeString}, 'Wboy', EmptyParam);
// Works          mydoc.saveas('C:\ThisWorks.doc');  (but I don't want to change the name)
// Doesn't work   Mydoc.close(wdSaveChanges);
except
  showmessage ('Tvajo matj');
end;

I just don't understand why MyDoc.Close(wdSaveChanges) would work after modifying the datasource, but not here?
0
Comment
Question by:Utvikler
  • 2
5 Comments
 
LVL 28

Expert Comment

by:TName
Comment Utility
Hi,
What does "Doesn't work" mean? Does it open a saveas box, does it close without saving, doesn't it close the doc at all?

You did previously open an existing document, I guess...
Is the document itself read-only?
Did you open it as read-only (third parameter in .Documents.Open, I think...)?
>mydoc.saveas('C:\ThisWorks.doc');
What happens if you use mydoc.save instead?
What happens if you replace 'C:\ThisWorks.doc' with the original name of the doc?
0
 

Author Comment

by:Utvikler
Comment Utility
Hi!

"Doesn't work" means closing without saving, no exceptions thrown.

The syntax "Mydoc.close(wdSaveChanges);" is used elsewhere in the application, and in those routines it works as expected.
I use it after changing datasource programmatically, and after assigning a value to a built-in document property.

The code here is just a modified version of setting the built-in props, so I just don't understand why it doesn't work here!

MyDoc.Save "fails" in the same way.

I haven't tried MyDoc.SaveAs (<original name>) yet.

Aaaaargh! What is so special about adding custom document properties???
0
 

Author Comment

by:Utvikler
Comment Utility
OK, I found a workaround here:

http://groups.google.no/group/microsoft.public.word.docmanagement/browse_thread/thread/1e76a0fc09ed4ecb/6ec1201e7a3648c6?lnk=st&q=Word+document+problem+close+wdSaveChanges&rnum=8&hl=no#6ec1201e7a3648c6

Thanks to THE Word Guru Cindy Meister!

>Aaaaargh! What is so special about adding custom document properties???

Sloppy programming comes to mind...  Shouldn't this be considered a bug?
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
Comment Utility
PAQed with points refunded (200)

Computer101
EE Admin
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
ADO Memory leak with DELPHI 2007 37 153
searching for DavidI's "Mobile Summer School download" 3 121
Delphi cmd execution 6 40
LAN or WAN ? 11 57
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now