Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Changes to Word doc by automation won't be saved

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

604 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