Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
| Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 3rd, 2005, 02:12 AM
Friend of Wrox
Points: 3,558, Level: 25
Points: 3,558, Level: 25 Points: 3,558, Level: 25 Points: 3,558, Level: 25
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: California, USA
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default Error in Office Programming

Hi all:
Im using Office Programming for my Automation App.
Everything is ok but there is a little problem. I've added an event on BeforeSave for my opened word from App. (the instance from Word.Application) then in BeforeSave even I save the content in a database & its ok then I close the word & then quit the word as follow:

Code:
Doc.SaveAs(.........);
Doc.Close(ref TempObj, ref TempObj, ref TempObj);
dbWord.Quit(ref TempObj, ref TempObj, ref TempObj);
by the way [u]
Code:
TempObj = System.Reflection.Missing.Value
</u>

It saves, close & quit word but Office gives me an error.
does anybody seen it!

Always:),
Hovik Melkomian.
__________________
Always,
Hovik Melkomian.
 
Old August 3rd, 2005, 06:18 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

I tried your code and didnt get any error. What error are you getting.
Could it be that it is an error caused by the code you wrote for database interaction.
 
Old August 4th, 2005, 03:21 AM
Friend of Wrox
Points: 3,558, Level: 25
Points: 3,558, Level: 25 Points: 3,558, Level: 25 Points: 3,558, Level: 25
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: California, USA
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

Well as I said before I get no error from Database & it saves its data into Table & then close & quit Word, it does all of it but then Word gives me error. I dont know why, & its same in other PCs'.
tnx for ur time.

Always:),
Hovik Melkomian.
 
Old August 6th, 2005, 03:03 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

It would realy help people understand the problem if you could write down exactly the error you are getting 'cause at times it is just a warning telling you that the default template has been changed or it could be that your application may cause security related exeptions trying to do away with the template after you have initiated the office application termination.

Regards
Ankur Verma
 
Old August 6th, 2005, 11:47 PM
Friend of Wrox
Points: 3,558, Level: 25
Points: 3,558, Level: 25 Points: 3,558, Level: 25 Points: 3,558, Level: 25
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: California, USA
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

dear Ankur:
as I said before! my code has no problem & I just got an error from Office prompting:

Microsoft Word has encountered a problem and needs to close. We are sorry for the inconvenience.
The information you were working on might be lost. Microsoft Word can try to recover it for you.

Recover my work and restart Microsoft Word

Please tell Microsoft about this problem.& bla bla...
& in Error report part It says:
Code:
AppName: winword.exe     AppVer: 10.0.2627.0     ModName: winword.exe
ModVer: 10.0.2627.0     Offset: 00234ab7
Always:),
Hovik Melkomian.
 
Old August 8th, 2005, 03:58 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

I wrote this simple minimal code with a handler for the Before Save event. This code is working fine. See if you can get some help out of it.

        private void WordApp_DocumentBeforeSave(Microsoft.Office.Intero p.Word.Document doc, ref bool SaveAsUI, ref bool Cancel)
        {
            doc.Content.Text += "TESIGN TESTING";
        }

        private void button1_Click(object sender, System.EventArgs e)
        {
            object TempObj = System.Reflection.Missing.Value;

            Microsoft.Office.Interop.Word.ApplicationClass aap = new Microsoft.Office.Interop.Word.ApplicationClass();
            Microsoft.Office.Interop.Word.Documents word = aap.Documents;

            String ss = "C:\\Test.doc";
            object ssO = ss;


            Microsoft.Office.Interop.Word.Document Doc = word.Open(ref ssO, ref TempObj, ref TempObj, ref TempObj, ref TempObj, ref TempObj, ref TempObj, ref TempObj, ref TempObj, ref TempObj, ref TempObj, ref TempObj, ref TempObj, ref TempObj, ref TempObj, ref TempObj);
            aap.DocumentBeforeSave += new Microsoft.Office.Interop.Word.ApplicationEvents4_D ocumentBeforeSaveEventHandler(
                WordApp_DocumentBeforeSave);

            Doc.Save();//(ref sssO, ref TempObj, ref TempObj, ref TempObj, ref TempObj, ref TempObj, ref TempObj, ref TempObj, ref TempObj, ref TempObj, ref TempObj, ref TempObj, ref TempObj, ref TempObj, ref TempObj, ref TempObj);
            Doc.Close(ref TempObj, ref TempObj, ref TempObj);
            aap.Quit(ref TempObj, ref TempObj, ref TempObj);
        }


Regards
Ankur Verma
 
Old December 13th, 2005, 09:19 AM
Registered User
 
Join Date: Dec 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Guys :D

i work with c# and programm a aplication that has a word export function but now i had a problem. The export Document must be save in a Database and not on the Harddrive. So i deactive the menucommand SaveAs.

The prob is that on the first time when the user open a new document and click on "save" a fileDialog is popup. So i use the Microsoft.Office.Interop.Word.ApplicationEvents4_D ocumentBeforeSaveEventHandler

to cancel theses saveprocess so that the user has now choise where he can save the file.

Here is my Eventcode...

        private void test(Microsoft.Office.Interop.Word.Document doc,ref bool a, ref bool cancel)
        {
                        //call my ManuelSaveRoutine
                        cancel = true;
        }

BUT the Save Routine will not abort

is this correct "cancel = true" ???

i click on "Save" and the FileDialog will popup but why -.-???

please help me :)

regards,
Taki.

 
Old August 17th, 2006, 07:53 AM
Registered User
 
Join Date: Aug 2006
Location: Swindon, Wiltshire, United Kingdom.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Melvik,

Did you ever resolve the above problem with Word?? I am experiencing the exact same thing.

Please can you share your resolution with me.

Thanks

Rob




Similar Threads
Thread Thread Starter Forum Replies Last Post
Error in Office Programming jasu C# 0 July 24th, 2007 04:19 AM
The Code of book ASP.NET Website Programming Error jackahu BOOK: ASP.NET Website Programming Problem-Design-Solution 0 June 16th, 2004 11:04 AM
error handling in asp.net e-commerce programming 123 All Other Wrox Books 0 October 19th, 2003 04:55 AM
.NET Network Programming Error TripleClamps All Other Wrox Books 0 August 13th, 2003 07:20 PM
.NET Network Programming Error TripleClamps .NET Web Services 0 August 13th, 2003 06:04 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.