Solved

Changes to Word doc by automation won't be saved

Posted on 2006-10-31
5
743 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 28

Expert Comment

by:TName
ID: 17848568
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
ID: 17849153
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
ID: 17854614
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
ID: 18061670
PAQed with points refunded (200)

Computer101
EE Admin
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 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