Click here to Skip to main content
15,888,461 members
Home / Discussions / C#
   

C#

 
GeneralRe: Export and save dataset to excel Pin
Programm3r22-Sep-09 1:26
Programm3r22-Sep-09 1:26 
AnswerRe: Export and save dataset to excel Pin
Amit Patel198521-Sep-09 23:35
Amit Patel198521-Sep-09 23:35 
QuestionIs it possible to reconnect an event without raising it? Pin
CBenac21-Sep-09 13:19
CBenac21-Sep-09 13:19 
AnswerRe: Is it possible to reconnect an event without raising it? Pin
Gideon Engelberth21-Sep-09 15:54
Gideon Engelberth21-Sep-09 15:54 
GeneralRe: Is it possible to reconnect an event without raising it? Pin
CBenac22-Sep-09 8:30
CBenac22-Sep-09 8:30 
QuestionHow to start a NamedPipeClientStream and a NamedPipeServerStream together Pin
AndyASPVB21-Sep-09 13:19
AndyASPVB21-Sep-09 13:19 
AnswerRe: How to start a NamedPipeClientStream and a NamedPipeServerStream together Pin
Michael Eber22-Sep-09 19:15
Michael Eber22-Sep-09 19:15 
QuestionSilverlight replace elements app Pin
User 602357121-Sep-09 11:14
User 602357121-Sep-09 11:14 
AnswerRe: Silverlight replace elements app Pin
Henry Minute21-Sep-09 11:35
Henry Minute21-Sep-09 11:35 
QuestionProblem with delegate for C++ DLL callback function Pin
Matthew Page21-Sep-09 11:10
Matthew Page21-Sep-09 11:10 
AnswerRe: Problem with delegate for C++ DLL callback function Pin
Matthew Page21-Sep-09 11:54
Matthew Page21-Sep-09 11:54 
QuestionAdding custom properties to a DataGridViewRow Pin
theallmightycpd21-Sep-09 9:33
theallmightycpd21-Sep-09 9:33 
AnswerRe: Adding custom properties to a DataGridViewRow Pin
Henry Minute21-Sep-09 11:41
Henry Minute21-Sep-09 11:41 
GeneralRe: Adding custom properties to a DataGridViewRow Pin
theallmightycpd22-Sep-09 3:39
theallmightycpd22-Sep-09 3:39 
GeneralRe: Adding custom properties to a DataGridViewRow Pin
Henry Minute22-Sep-09 4:08
Henry Minute22-Sep-09 4:08 
QuestionUsing StringBuilder inside another class? Pin
helfri6221-Sep-09 9:27
professionalhelfri6221-Sep-09 9:27 
AnswerRe: Using StringBuilder inside another class? Pin
Luc Pattyn21-Sep-09 9:40
sitebuilderLuc Pattyn21-Sep-09 9:40 
GeneralRe: Using StringBuilder inside another class? Pin
helfri6221-Sep-09 10:00
professionalhelfri6221-Sep-09 10:00 
GeneralRe: Using StringBuilder inside another class? Pin
Luc Pattyn21-Sep-09 10:10
sitebuilderLuc Pattyn21-Sep-09 10:10 
QuestionThread reach synchronized code block Pin
FJJCENTU21-Sep-09 6:33
FJJCENTU21-Sep-09 6:33 
AnswerRe: Thread reach synchronized code block Pin
N a v a n e e t h21-Sep-09 7:01
N a v a n e e t h21-Sep-09 7:01 
Question[SOLVED] File Encryption Broken [modified] Pin
Ben Magee21-Sep-09 6:26
Ben Magee21-Sep-09 6:26 
NewsRe: File Encryption Broken Pin
Ben Magee21-Sep-09 6:41
Ben Magee21-Sep-09 6:41 
QuestionPlease help me about working with Word - Very URGENT Pin
designervc21-Sep-09 6:18
designervc21-Sep-09 6:18 
Hi everybody,
Now, I have to create a Word file from a word template, i have faced a difficult problem when replace a text on Word file.

In my file Word template, I have 5 lines with the text is "Name_of_Applicant". (Please note that the BOOKMARK will not use in this template)

In my C# code, I would like to do as follows:
1. Find the text "Name_of_Applicant" and Replace it.

2. I do Foreach(Word.Range tmpRange in oWordDoc.StoryRanges) { ... do something ... }. In the FOR loop, I will replace 5 lines as "Name_1", "Name_2", .... , "Name_5".

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

    oWord = new Word.Application();
    oWordDoc = new Word.Document();
    oWord.Visible = true;
    oWord.NormalTemplate.Saved = true;

    oTemplatePath = "D:\\Template.doc";
    oWordDoc = oWord.Documents.Open(ref oTemplatePath, ref oMissing, ref readOnly, ref readOnly, ref oMissing, ref oMissing, ref readOnly, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);

    object findText = "Name_of_Applicant";
    try
    {
        int index_name = 0;
        object oReplace = "Name_" + index_name.ToString();
        foreach (Word.Range tmpRange in oWordDoc.StoryRanges)
        {
            //The Paramater 11 is the REPLACED text
            if (oWord.Application.Selection.Find.Execute(ref findText, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oReplace, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing))
            {
                index++;
            }
        }
    }
    catch
    {
        MessageBox.Show("The text could not be located.");
    }
}



The code above is only one of many different way that I have tried, but I have only replace the FIRST line.

Do you have any idea for this problem. It's will be appreciate your help so much.

Thank you
QuestionSocket programming problem Pin
JLP18821-Sep-09 6:07
JLP18821-Sep-09 6:07 

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.