Solved

Changes to Word doc by automation won't be saved

Posted on 2006-10-31
5
738 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to fill array with TArray.Create? 14 77
Strange behavior when a form is closed 6 50
control image tags in a string ? 12 110
CheckListBox usage 3 48
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

932 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

19 Experts available now in Live!

Get 1:1 Help Now