Category Archives: Office

Convert RTF and TXT files into DOCX files in C#

First add a reference to Microsoft.Office.Interop.Word. To make using the library easier, add this using statement: using Word = Microsoft.Office.Interop.Word; When you enter the input and output file names and click Convert, the program uses the following code to open … Continue reading

Posted in files, interoperability, Office, Word | Tagged , , , , , , , , , , , , , | Leave a comment

Convert doc files into docx files in C#

This example shows how to write a C# program to automatically convert doc files into docx files. In a previous version of Windows, whenever I double-clicked a .doc file, I got this error message: Error The operating system is not … Continue reading

Posted in Office, Word | Tagged , , , , , , , , , , , , | Leave a comment

Load a CSV file in Excel in C#

Loading a CSV file (comma-separated value file) into Excel isn’t too hard once you know the tricks. Using the same tricks you can load a file that uses any delimiter, not just a comma. First at design time, add a … Continue reading

Posted in Excel, files, Office | Tagged , , , , , , , , , , , , | 5 Comments

Make an Excel chart in C#

This example uses the following code to create an Excel chart in a new workbook. private void btnCreateChart_Click( object sender, EventArgs e) { // Get the Excel application object. Excel.Application excel_app = new Excel.ApplicationClass(); // Make Excel visible (optional). excel_app.Visible … Continue reading

Posted in Excel, interoperability, Office | Tagged , , , , , , , , , , | Leave a comment

Add and remove pictures in an Excel worksheet

This is another brief foray into VBA programming. When you click the Insert Image button, the following VBA code executes. ‘ Insert a picture at the selection. Sub Button1_Click() Dim filters As String Dim filename As Variant ‘ Define the … Continue reading

Posted in Excel, Office, VBA | Tagged , , , , , , , , , | Leave a comment

Save images in an Access database in WPF and C#

The example Display images in an Access database in WPF and C# shows how you can display images saved in an Access database. Of course that begs the question, “How do you save images in the database in the first … Continue reading

Posted in database, graphics, image processing, Office | Tagged , , , , , , , , , , , , , , , | Leave a comment

Display images in an Access database in WPF and C#

This example shows how you can display images stored in an Access database in a WPF program. You can do this with bound controls, but I find this approach less confusing because you do everything explicitly in code. When the … Continue reading

Posted in database, graphics, image processing, Office | Tagged , , , , , , , , , , | Leave a comment

List the unique words in a Microsoft Word file in C#

The example List unique words in a text file in C# shows how to list the unique the words in a text file. This example shows how to list the unique words in a Microsoft Word file. Before you start, … Continue reading

Posted in files, Office, strings, Word | Tagged , , , , , , , , , , , , | Leave a comment

Remove the hyperlinks from a Word document in C#

This example shows how you can remove the hyperlinks from a Word document. When you select text on a web page and paste it into a Word document, the result often contains hyperlinks that you don’t want. (Actually after you … Continue reading

Posted in files, Office, Word | Tagged , , , , , , , , , , , | Leave a comment

Add a picture to a Word document in C#

This example shows how a C# program can add a picture to a Word document. It also shows how to use a bookmark to find the beginning of the Word document, make text flow around the picture, and align the … Continue reading

Posted in interoperability, Office, Word | Tagged , , , , , , , , , , , , , , , | 2 Comments