Click here to Skip to main content
15,922,512 members
Home / Discussions / COM
   

COM

 
GeneralRe: How do I determine if a certain method exists on an interface? Pin
Bo Hunter7-Jan-04 3:12
Bo Hunter7-Jan-04 3:12 
GeneralIs it necessary to Implement class factory interface Pin
Omar Alvi5-Jan-04 1:39
Omar Alvi5-Jan-04 1:39 
GeneralRe: Is it necessary to Implement class factory interface Pin
Vi25-Jan-04 22:06
Vi25-Jan-04 22:06 
GeneralOut-of-proc weirdness: Case Closed Pin
Jörgen Sigvardsson4-Jan-04 23:33
Jörgen Sigvardsson4-Jan-04 23:33 
GeneralReleasing IDirectinputdevice interface Pin
Manju4-Jan-04 21:50
Manju4-Jan-04 21:50 
GeneralRe: Releasing IDirectinputdevice interface Pin
JJeffrey7-Jan-04 14:27
JJeffrey7-Jan-04 14:27 
GeneralOutlook Rule programming Pin
nightcoder4-Jan-04 7:14
nightcoder4-Jan-04 7:14 
GeneralUsing Word i nC# Pin
Stephane David3-Jan-04 5:43
Stephane David3-Jan-04 5:43 
I've tried to used this article http://www.codeproject.com/csharp/CsAutomateWord.asp?target=Word to create a character sheet.

I have a CCharacter class, that contains all information about a character, and I want to generate a MS Word document with these information.

So I've created .dot document, with thinks like
Name _Name_ Age _Age_
in arrays (I've tried also without the array, directly in the text). _XXX_ is code that I will use for replacement.

Now, to the code:

// Create a Word application
Word.ApplicationClass vk_word_app = new Word.ApplicationClass();
// Open the .dot
object FileName =Directory.GetCurrentDirectory()+"\\Models\\Sheet.dot";
Word.Document vk_my_doc = vk_word_app.Documents.Open(...
// Create a new document
Word.Document vk_new_doc = vk_word_app.Documents.Add((...
// Copy the .dot into the new document
vk_my_doc.Select();
vk_word_app.Selection.Copy();
vk_new_doc.Select();
vk_word_app.Selection.PasteAndFormat(Word.WdRecoveryType.wdPasteDefault);
// close the .dot
vk_my_doc.Close( ref vk_false, ref vk_missing, ref vk_missing );

All the previous steps work. I get a new document, build from my template.

Now, I'd like to fill it with actual information. So I do this

// Select the new doc
vk_new_doc.Select();
// Define some variable
object vk_false = false;
object vk_true = true;
object vk_num = Word.WdFindWrap.wdFindStop;
object vk_find = "_Nom_";
object vk_replaceWith = Name_Familly; // This one is a member of CCharacter class
object vk_replace = Word.WdReplace.wdReplaceOne;

// Try to replace the text
vk_word_app.Selection.Find.Execute( ref vk_find,
ref vk_false, ref vk_false,
ref vk_false, ref vk_false, ref vk_false, ref vk_true,
ref vk_num, ref vk_false,
ref vk_replaceWith, ref vk_replace, ref vk_false,
ref vk_false, ref vk_false, ref vk_false );

And... it doesn't work.

I got this error:

System.Runtime.InteropServices.COMException (0x800706F7): Le relais a reçu des données incorrectes.
at Word.Find.Execute(Object& FindText, Object& MatchCase, Object& MatchWholeWord, Object& MatchWildcards, Object& MatchSoundsLike, Object& MatchAllWordForms, Object& Forward, Object& Wrap, Object& Format, Object& ReplaceWith, Object& Replace, Object& MatchKashida, Object& MatchDiacritics, Object& MatchAlefHamza, Object& MatchControl)

My form close, the word doc stays opened.


"Le relais a reçu des données incorrectes" would translate as "incorrect data received".


Any idea of a way to solve this would be greatly welcomed!




GeneralImplentation of Pin
SiddharthAtw2-Jan-04 1:54
SiddharthAtw2-Jan-04 1:54 
GeneralRe: Implentation of Pin
Heath Stewart3-Jan-04 8:19
protectorHeath Stewart3-Jan-04 8:19 
GeneralRe: Implentation of Pin
Anonymous3-Jan-04 19:19
Anonymous3-Jan-04 19:19 
QuestionHow to bypass login window? Pin
SiddharthAtw31-Dec-03 0:03
SiddharthAtw31-Dec-03 0:03 
AnswerRe: How to bypass login window? Pin
valikac2-Jan-04 11:48
valikac2-Jan-04 11:48 
GeneralRe: How to bypass login window? Pin
SiddharthAtw2-Jan-04 18:20
SiddharthAtw2-Jan-04 18:20 
Generalhelp in an active x control Pin
safee ullah30-Dec-03 18:52
safee ullah30-Dec-03 18:52 
GeneralRe: help in an active x control Pin
bryce30-Dec-03 19:13
bryce30-Dec-03 19:13 
GeneralRe: help in an active x control Pin
Abhishek Srivastava30-Dec-03 19:34
Abhishek Srivastava30-Dec-03 19:34 
QuestionHow to develop pluggable application? Pin
Anonymous30-Dec-03 11:06
Anonymous30-Dec-03 11:06 
AnswerRe: How to develop pluggable application? Pin
Tristan Rhodes30-Dec-03 13:46
Tristan Rhodes30-Dec-03 13:46 
GeneralPassing CRichEditCtrl pointer to COM Pin
BazM30-Dec-03 10:08
BazM30-Dec-03 10:08 
GeneralRe: Passing CRichEditCtrl pointer to COM Pin
BazM31-Dec-03 3:02
BazM31-Dec-03 3:02 
GeneralForward Defining Structures Pin
Tristan Rhodes30-Dec-03 9:22
Tristan Rhodes30-Dec-03 9:22 
QuestionWho can tell me GUIDGEN.EXE three item mean? Pin
Peng Yao29-Dec-03 21:55
sussPeng Yao29-Dec-03 21:55 
AnswerRe: Who can tell me GUIDGEN.EXE three item mean? Pin
geo_m30-Dec-03 0:24
geo_m30-Dec-03 0:24 
Generalmidl problems Pin
Tristan Rhodes28-Dec-03 6:05
Tristan Rhodes28-Dec-03 6:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.