Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
C

Cyrus IRA

@Cyrus IRA
About
Posts
3
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • replace a Text in winword within a range
    C Cyrus IRA

    ... [START] blaaa blaa blaa T h i s (this is an empty line) {END] ... another line -------------------------------------- I have been trying to remove empty lines appearing between [START] and {END] within a word document. Code seems to work if I did not have a textbox at top of my document. It seems that the textbox is also cleared once such operation takes place.

                wordapp = new Word.Application();
                wordapp.Visible = false;
                doc = wordapp.Documents.Open(wordPath);
                paragraphs = doc.Paragraphs;
                bool flag = false;
    
                foreach (Word.Paragraph paragraph in paragraphs)
                {
                    string s = paragraph.Range.Text;
                    string y = paragraph.Range.Text.Trim();
    
                    if (paragraph.Range.Text == "\\r")
                    {
                        flag = true;
                        paragraph.Range.Select();
                        wordapp.Selection.Delete();
                        continue;
    
                    }
                    else if (paragraph.Range.Text == "\\r")
                    {
                        flag = false;
                        paragraph.Range.Select();
                        wordapp.Selection.Delete();
                        continue;
                    }
                    else if (paragraph.Range.Text.Trim() == string.Empty )
                    {
                        if (flag)
                        {
                            paragraph.Range.Select();
                            wordapp.Selection.Delete();
                        }
                        continue;
                    }
    
                }
    
                // Save the document and close document 
                doc.Save();
                // Quit the word application 
                wordapp.Quit();
    

    is there any other way to achieve what I do using Range in Word or dealing with a textbox in Word?

    Student of life

    C# question

  • app config
    C Cyrus IRA

    Tried config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoaming); crashed at Config.Save.

    C# help question workspace

  • app config
    C Cyrus IRA

    Problem occurs when I exit out of the application. static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } Whatever has been written to my config file and saved to the file goes back to what it used to before. I have no idea why ? Do you guys have any idea? System.Configuration.Configuration config = null; config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); config.AppSettings.Settings.Add(strJob, strValue); config.Save();

    C# help question workspace
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups