 |
| 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
|
|
|
|

August 3rd, 2005, 02:12 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
|
|
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.
|
|

August 3rd, 2005, 06:18 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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.
|
|

August 4th, 2005, 03:21 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
|
|
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.
|
|

August 6th, 2005, 03:03 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|
|

August 6th, 2005, 11:47 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
|
|
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.
|
|

August 8th, 2005, 03:58 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|
|

December 13th, 2005, 09:19 AM
|
|
Registered User
|
|
Join Date: Dec 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

August 17th, 2006, 07:53 AM
|
|
Registered User
|
|
Join Date: Aug 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|
 |