Total members 11895 |It is currently Sun Dec 22, 2024 4:10 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Dear All,

Using C# and word object model, i am automate the process, where based on the tag name present in the document its corresponding style has to be applied for the paragraph.
For instance:
<H1>This is Heading1
<Para>This is Paragraph sample...

Our task is to find the <H1> tag and replace it with "H1" style for the whole document.

Below is the code where I can open the document and add the template styles into the current file.

Code:
ApplicationClass objWordApp = new ApplicationClass();
Document objWordDoc = new Document();         

foreach (string eachfile in lstfile.Items)
{
                Object nothing = System.Reflection.Missing.Value;
                Object fileName = txtFilename.Text.ToString();
                Object notTrue = false; 
                Object missing = System.Reflection.Missing.Value;
                objWordDoc = null;

                Object readOnly = false;
                Object isVisible = false;

                objWordApp.Visible = false;

                objWordDoc = objWordApp.Documents.Open(ref fileName, ref

missing,
                      ref readOnly, ref missing, ref missing, ref missing,
                      ref missing, ref missing, ref missing, ref missing,
                      ref missing, ref isVisible, ref missing, ref missing,
                      ref missing, ref missing);
                objWordDoc.Activate();
                objWordApp.Visible = false;

                string InDoc = OPagPath + "\\" + eachfile;
                objWordApp.Selection.InsertFile(PagFpath, ref missing, ref missing, ref

missing, ref missing);

   //Here I need help to find and replace with particular style
}

objWordApp.Quit(ref notTrue, ref missing, ref missing);


I need your help/suggestion to find text and replace with corresponding style.

Thanks,
Rangesh




Author:
Newbie
User avatar Posts: 1
Have thanks: 0 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : C# Word Styling Automation
 Jobs-130747-Automation Tester in Bangalore, Hyderabad     -  
 word counts in php     -  
 Word & ASP.Net ISSUE     -  
 convert word, Excel to PDF     -  
 Simple Word Program     -  
 Change the word spacing in paragraph     -  
 java code to open word doc attached in ms access.db     -  



cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com