?
Solved

Changes to Word doc by automation won't be saved

Posted on 2006-10-31
5
Medium Priority
?
746 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month11 days, 22 hours left to enroll

752 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