Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7888579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:52:04+00:00 2026-06-03T05:52:04+00:00

I am wanting to replace all the substitue code for paragraph markers (^13) with

  • 0

I am wanting to replace all the substitue code for paragraph markers (^13) with the normal paragraph marker code ^p in a Microsft Word document, using C# and Interop.

I am have been using the Microsoft.Office.Interop.Word.Selection.Find.Execute() method.

For example..

    .Application.ActiveWindow.Selection.Find.Execute(
               ref findText,
               ref matchCase,
               ref matchWholeWord,
               ref matchWildcards,
               ref matchSoundsLike,
               ref matchAllWordForms,
               ref findForward,
               ref findWrap,
               ref findFormat,
               ref replaceText,
               ref replaceAll,
               ref missing,
               ref missing,
               ref missing,
               ref missing);
  • findText = “^13”
  • matchCase = true
  • matchWholeWord = true
  • matchWildcards = true
  • matchSoundsLike = false
  • matchAllWordForms = false
  • findForward = true
  • findWrap = WdFindWrap.wdFindContinue
  • findFormat = false
  • replaceText = “^p”
  • replaceAll = WdReplace.wdReplaceAll

Using the code above, the ^13 markers are not being replaced by ^p markers.

Does anyone know how I can rectify this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:52:05+00:00Added an answer on June 3, 2026 at 5:52 am

    check my codes below:

     // Create the Word application and declare a document
                Word.Application word = new Word.Application();
                Word.Document doc = new Word.Document();
    
                // Define an object to pass to the API for missing parameters
                object missing = System.Type.Missing;
    
                try
                {
                    // Everything that goes to the interop must be an object
                    object fileName = @"D:\test.docx";
    
                    // Open the Word document.
                    // Pass the "missing" object defined above to all optional
                    // parameters.  All parameters must be of type object,
                    // and passed by reference.
                    doc = word.Documents.Open(ref fileName,
                        ref missing, ref missing, ref missing, ref missing,
                        ref missing, ref missing, ref missing, ref missing,
                        ref missing, ref missing, ref missing, ref missing,
                        ref missing, ref missing, ref missing);
    
                    // Activate the document
                    doc.Activate();
    
                    // Loop through the StoryRanges (sections of the Word doc)
                    foreach (Word.Range tmpRange in doc.StoryRanges)
                    {
                        // Set the text to find and replace
                        tmpRange.Find.Text = "xml";
                        tmpRange.Find.Replacement.Text = "XML";
    
                        // Set the Find.Wrap property to continue (so it doesn't
                        // prompt the user or stop when it hits the end of
                        // the section)
                        tmpRange.Find.Wrap = Word.WdFindWrap.wdFindContinue;
    
                        // Declare an object to pass as a parameter that sets
                        // the Replace parameter to the "wdReplaceAll" enum
                        object replaceAll = Word.WdReplace.wdReplaceAll;
    
                        // Execute the Find and Replace -- notice that the
                        // 11th parameter is the "replaceAll" enum object
                        tmpRange.Find.Execute(ref missing, ref missing, ref missing,
                            ref missing, ref missing, ref missing, ref missing,
                            ref missing, ref missing, ref missing, ref replaceAll,
                            ref missing, ref missing, ref missing, ref missing);
                    }
    
                    // Save the changes
                    doc.Save();
    
                    // Close the doc and exit the app
                    doc.Close(ref missing, ref missing, ref missing);
                    word.Application.Quit(ref missing, ref missing, ref missing);
                }
                catch (Exception ex)
                {
                    doc.Close(ref missing, ref missing, ref missing);
                    word.Application.Quit(ref missing, ref missing, ref missing);
                    System.Diagnostics.Process.Start("D:\\test.docx");
                }
    

    One more thing: Note here: using Word = Microsoft.Office.Interop.Word;

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm wanting to rewrite Word Press urls using mod_rewrite in my .htaccess file in
I am wanting to replace all non letter and number characters i.e. /&%#$ etc
I'm wanting to get the filepath ie /sites/default/files/myfile.pdf for my file uploads. I'm using
I have a JSP page that renders a block of HTML. In normal usage,
I'm wanting to optimize a query using a union as a sub query. Im
I thought I had this figured out, but I'm wanting to find all occurances
I have more 3000 files in a folder. I want to find and replace
In the process of converting a page from normal postbacks to AJAX-calls (using JavaScript
My colleagues are going crazy because I keep on wanting to rewrite code that
I have a app where people can delete stuff. I am wanting to disable

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.