Click here to Skip to main content
15,891,914 members
Everything / Productivity Apps and Services / Microsoft Office / Office Automation

Office Automation

Office-Automation

Great Reads

by simonp_ca
Use Excel worksheet's cells as pixels to render real image (for fun and experiment)
by Dracula
Run all rules for all accounts on all messages; also useful as Outlook Rule debug tool.
by pramod.hegde
Merge slides from multiple presentations to one at a desired position
by Tim Cadenbach
License Verification Attribute for MVC and Office-Addins

Latest Articles

by Gaston Verelst
How to create a Visio Add-in in VS2017
by simonp_ca
Use Excel worksheet's cells as pixels to render real image (for fun and experiment)
by Dracula
Run all rules for all accounts on all messages; also useful as Outlook Rule debug tool.
by Six Hat Solutions
Easily Send Emails From Your Microsoft Applications Using VBA and the SendGrid API

All Articles

Sort by Updated

Office Automation 

1 Dec 2023 by Andre Oosthuizen
Yes, it is possible in C#, VB.NET and some others as well. The below is for C# to reference your question - You can pick up on all of the basics as a starting point at - How to access Office interop objects | Tutorial[^] Some code to point you...
1 Dec 2023 by Maciej Los
Couldn't it be better to re-write all macros from VBA to C#? Whatever you want to do with Excel data, you can do it in C#. Take a look at EPPlus library[^]. This library is powerful, elastic. You don't need to have an Office installed on your...
1 Dec 2023 by Peter Abbasi
Hey everyone, Noob here who -- not necessarily because it's the best solution but more so just to learn and this is my idea of fun -- wants to write a super simple C# standalone app that (a) displays a list of macros I've written in VBA and (b)...
27 Jun 2023 by Michael Haephrati
When the active document is part of the OneDrive folder, the return value is a URL, even though the document is stored locally. What I am looking for, is a solution to get the local path of the active document regardless of it being synced with...
27 Jun 2023 by Michael Haephrati
Here is a quick and dirty solution. OLECHAR* OfficeAutomation::GetActiveDocPath() { VARIANT result; VariantInit(&result); m_hr = OLEMethod(DISPATCH_PROPERTYGET, &result, m_pActiveDocument, (LPOLESTR)L"Path", 0); if (FAILED(m_hr))...
30 Aug 2021 by Aashish_stellar
Hello, I am working on .xlsx file on windows in VC++ MFC and trying to create table in its worksheets. I am using XLS2007::ListObjects::add function for creating table but function fails every time. Please have a look what I am doing: What I...
30 Aug 2021 by Maciej Los
As per documentation, a ListObject.Add function requires to define a sheet in which the list is added. For example: Set objListObject = ActiveWorkbook.Worksheets(1).ListObjects.Add(SourceType:= xlSrcExternal, _ Source:= Array(strServerName,...
7 Jun 2021 by Member 15235350
Microsoft Office 2007 only came in 32-bit. To confirm this, first open a microsoft office product. Open the task manager by pressing Cntl+ Shift + Esc. Then make sure you are in the Processes tab. Find the office 2007 program you are...
11 May 2021 by Juliett Kilo
Hi, In our VSTO document-level add-in we have to reliably store the contents of RichText ContentControls in a persistable form, for later restoration in its original form. As the documentation of both Interop and VBA APIs seems to tell, this...
13 Nov 2018 by M. Faisal Hafeez
I'm trying to open a existing PowerPoint slide in WPF program. I would like to view and edit .ppt file in WPF window at same time.Further I want to embed annotated notes on slides(Like ink in MS-Word) and save these notes along slides for future use. After editing .ppt file should be compatible...
13 Nov 2018 by Aydin Homay
Hi, What comes to my mind is the use of office development in visual studio which allows you to embed office (word, excel, power point) inside of your wpf or winform application. See the below link for more information. Office client development | Microsoft Docs[^] Another links: Embedding MS...
4 Mar 2018 by Gaston Verelst
How to create a Visio Add-in in VS2017
22 Feb 2018 by Умрбек Матрасулов
what we have: a database with 134 columns, and about 200,000 rows what I want: 1. at the required time, from the computer upload to web site database in excel format. 2.Users should be able to edit, correct, fill-in, save at the same time. 3.Users should be able to unload the database in Excel...
22 Feb 2018 by OriginalGriff
There isn't any "standard web site feature" that will let you do that - especially the last one! Most companies and sites try really hard to prevent users downloading their databases, not tries to expose them for download by users. So I'm sorry, but you will have to either learn to code, or pay...
30 Aug 2017 by simonp_ca
Use Excel worksheet's cells as pixels to render real image (for fun and experiment)
10 Jul 2017 by abdul subhan mohammed
Dear All, I have created Windows application where automating MsOffice. I have to evaluate inserted sparkline(would like fetch: type, theme, color, etc) in the excel worksheet(already exists). What I have tried: public static bool EvaluateSparkline(IQuestion question, string filename,...
10 Jul 2017 by Richard MacCutchan
SparklineGroups excel interop - Google Search[^]
8 Jun 2017 by abdul subhan mohammed
Dear All, I'm creating a windows application in c# where automating MsOffice Excel. I want to change the view type of excel worksheet, programmatically. Click here for more details What I have tried: can any one please help me. Thanks in advance
8 Jun 2017 by ZurdoDev
You can record a macro, as Richard mentioned, doing what it is you want and then look at the code. You can then translate it into C# pretty easily generally speaking.
7 Jun 2017 by abdul subhan mohammed
Dear All, I'm creating a windows application in c# where automating MsOffice Excel. I want to find range of columns was sorted or not. I searched on google but i didn't find any solution, but sorting. What I have tried: Can anyone please help me, how can i find out the range of columns was...
7 Jun 2017 by Richard MacCutchan
Rather than repeatedly posting all your questions here, you should study the interop documentation: Microsoft.Office.Interop.Excel namespace ()[^], or hire a programmer who already knows it.
6 Jun 2017 by Maciej Los
Check this: VBA auto hide ribbon in Excel 2013 - Stack Overflow[^] A C# form may look like: excelApplication.CommandBars.ExecuteMso "HideRibbon" [EDIT] "HideRibbon" is the name of ribbon you have to change. To get list of IdMso, please see: Ribbon Examples files and Tips[^]
6 Jun 2017 by abdul subhan mohammed
Dear All, I'm creating windows application in c#, where automating MsOffice Excel. I'm trying to get excel application ribbon is currently hide/show. Following code: What I have tried: public static bool EvaluateRibbonDisplay(IQuestion question, string filename, ShowHide display) ...
6 Jun 2017 by Richard MacCutchan
See How to hide ribbon display in excel using C#[^].
5 Jun 2017 by abdul subhan mohammed
Dear All, I'm creating a windows application in c#, automating MsOffice Excel. i'm trying to hide ribbon display but its not hiding the ribbon. What I have tried: public static bool ChangeRibbonDisplay(IQuestion question, string filename, ShowHide display) { ...
22 May 2017 by abdul subhan mohammed
Dear All, I have created MsOffice Template application in windows using office interop in C#. I want to retrieve text from table_of_contents and indexes which are already in word document. MyCode: What I have tried: public static bool EvaluateTableOfContents(IQuestion question, string...
22 May 2017 by abdul subhan mohammed
I got the solution if(tableOfContents.Count > 0) { WordInterop.Range range = tableOfContents[_index].Range; if (range.Find.Execute(text)) result = true; } if (index.Count > 0) ...
17 May 2017 by PBGuy
Hie,I have trouble inserting SMART ART in powerpoint through c# code. Error is shown, when I try to add smart art to the slide,I triedPowerPoint.Shape shape = objSlide.Shapes.AddSmartArt(objSlide.Application.SmartArtLayouts[3], 10, 125);Do I need to reference additional dlls? I...
17 May 2017 by abdul subhan mohammed
Just change word to powerpoint, hope this will help you! public static bool InsertSmartArtShape(IQuestion question, string filename, SmartArtShapes _smartArtShape) { WordInterop.Application wordApplication = GetOrCreateWordApplication(question.ObjectStore); ...
17 May 2017 by abdul subhan mohammed
Dear All, I want to evaluate smartart shape, which is already inserted in the existing word document. Where the document contain n number of smartart shapes. I alreay searched on google regarding this, but I did not find suitable one. Please review my code.... What I have tried: public...
17 May 2017 by abdul subhan mohammed
public static bool EvaluateSmartArtShape(IQuestion question, string filename, SmartArtShapes _smartArtShape) { WordInterop.Application wordApplication = GetOrCreateWordApplication(question.ObjectStore); try { //Avoid screen...
9 May 2017 by abdul subhan mohammed
Dear All, We are automating MsOffice in winform application(C#). Currently we are working on, to create a powerpoint file(Programmatically). We are successfully created pptx file. After creating a pptx file, we are trying to close both the presentation and application. Its clsoing only...
9 May 2017 by Maciej Los
I'd suggest to read this: Office application does not quit after automation from Visual Studio .NET client[^] You have to "clean up" by using Marshal.ReleaseComObject Method (Object) (System.Runtime.InteropServices)[^] directly on your ppt application object (instance).
2 May 2017 by abdul subhan mohammed
Dear All, We are automating MsOffice in our winForm application(C#). Where I have create one method to "Evaluate the paragraph line spacing". In the word document, there will be paragraphs and this method will find the line spacing from the specific paragraph. I have set the paragraph line...
2 May 2017 by Wessel Beulink
As far as I know you need to set the Paragraph linespacing before getting the result or change it. Selection.ParagraphFormat.LineSpacingRule = WdLineSpacing.wdLineSpaceSingle;
3 Mar 2017 by Dracula
Run all rules for all accounts on all messages; also useful as Outlook Rule debug tool.
27 Sep 2016 by Rohit daga
I am creating one slide PowerPoint file using open XML. I have tagged the placeholder in the PPT which i need to update programatically. I am able to find the placeholder and can update its value from the database.Now the problem is I need to display some HTML code which user has input using...
15 Sep 2016 by Yesudasan Moses
Hi friends,I have developed one Plugin for Outlook in Visual Studio 2010 using C#. It works perfectly in 2007, but not working in 2013.How can I develop Plugins for 2013. What tools should I use ???
2 Jul 2016 by Six Hat Solutions
Easily Send Emails From Your Microsoft Applications Using VBA and the SendGrid API
30 Mar 2016 by ChadFolden1
Extract Microsoft Outlook messages from a PST into a folder structure
25 Dec 2015 by Tim Cadenbach
License Verification Attribute for MVC and Office-Addins
14 Dec 2015 by bradyguy
Don't send your mail out using the wrong account
19 Jul 2015 by kedar001
for intranet application, I used 'Macro' to Update All the Fields in the Active Document. Now i want to deploy this Macro from server on each client browsing my application.i have tried with a link to download a .Bat file in .bat filecopy \\serverName\Sharedfolder\Normal.dot ...
12 Feb 2015 by M Mehta
Hi,Use the code as followsDim con As New ADODB.Connectioncon.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & CurrentProject.FullNamecon.Open;;; your code ;;;;con.CloseHope this helps
11 Feb 2015 by Pravinkarne.31
Hello Team, I have cretaed a Tool in MS Access 2007 to generate few reports in Excel. This tool is running perfectly fine till y'day since last two years. But Today I have upgrated MS Office 2007 with MS office 2010 (Except Access - So MS Access I have is 2007) Now when I run my...
13 Jan 2015 by Sivaji1565
HiI need to change the name of the Insert tab dynamically using C# addin. I am using MS Office 2007. I tried the following xml, I can see my custom group and button in insert tab but tab name is not getting changed.
12 Jan 2015 by Member 11255065
I want to get all the headings along their sub-headings separately from a word file programmatically Using c# for example i have following content :HEADING 1 XYZheading 2heading 3HEADING 1 ABCHEADING 1 DEFheading 2 lorem ispumso my code should return me:Heading 1...
2 Sep 2014 by Sergey Alexandrovich Kryukov
Browsers are not supposed to support this proprietary format. Even if you want your solution to be based on the MS Office format (which I would not recommend, but many sites to exactly that), you would need to define some mapping between some class of documents and HTML, represent the document...
2 Sep 2014 by Raj_3
I have a requirement to create a web application where user will be able to view and edit MS Excel/Doc files directly in web browser without having installed MS office on his machine. MS office would be installed on only server where this application will be hosted. Please suggest the...
7 Aug 2014 by roli.hof
This article describes a windows forms application which automates MS Office PowerPoint 2007 in order to replace predefined text of a template with your input
24 Jun 2014 by RCWL
Hi,I'm currently building an add-in for Project 2013 and need to capture the file print event.As far as I know, the only available event handlers are Application.ProjectBeforePrint and Project.BeforePrint, but both seems to get invoked when:1. Clicking on the Print option within the...
22 Apr 2014 by Member 10354292
Hi, I have application with word automation in C# with office interop. Now as we moved to win server 2008, it not working and not recommended by microsoft. In our application user will download the templates from DB and merge the data and upload back to DB.All the templates are in office...
20 Feb 2014 by Bernhard Hiller
What do you expect with the presentation to happen? There is no screen attached to the session of IIS on the server, it won't be opened on the client computer, and the user won't see it!In your case, IIS might not have access rights to the file on the level of the file system.Microsoft...
11 Feb 2014 by PBGuy
Hi,I need to create and later update charts in powerpoint slide, on clicking a button from task pane in powerpoint presentation. I was able to create custom ribbons and task panes and interact with slides in the presentation. I was unable to find the ways to populate a chart with data...
5 Feb 2014 by LazyCoder0
This article describes how to merge PowerPoint Presentations (PPTX format) and save as PDF in .NET applications using Office Automation (OpenXML SDK).
20 Nov 2013 by Terence Wallace
Ordermate can be used as a basic example of utilizing the XMLSerializer class to automate the creation of invoice forms.
24 Oct 2013 by moon_lu
VARIANT _stdcall AAs(BSTR pfieldlist){ ::CoInitialize(NULL); VARIANT v;v.vt = VT_BSTR; CComQIPtr spApp(g_Application); long a = spApp->ThisCell->Row; long b = spApp->ThisCell->Column; a++; CString str; str.Format("a = %d b =...
6 Sep 2013 by moon_lu
Is there any article about introducing Excel asynchronous UDF?http://social.msdn.microsoft.com/Forums/office/en-US/25ca9321-4abf-4fb5-a25b-d4ce5c3f54e1/how-to-implement-asynchronous-function-in-excel-2003[^]
7 Aug 2013 by Member 8022123
Just remove FindNext(), Instead used Find() twice :) //find for word in a range objFoundRng = objRange.Find(COleVariant(strSearchStr), VOptional, xlValues, xlPart, xlByRows, xlNext, vFalse, VOptional, VOptional); //find for next occurence if(objFoundRng !=...
4 Aug 2013 by Maciej Los
Rather than seraching MS Excel using Find and/or FindNext function, use ADO.NET ;) It's much. much quickest...Data Access Using ADO.NET in C++ [^]MoreVisual Studio samples[^]C++ app automates Excel (CppAutomateExcel)[^]
3 Aug 2013 by Member 8022123
Hi All,I am trying to search a string in MSExcel sheet using following source code in VC++,MFC.First occurrence of string is found using Range.Find() but for next occurrence Range.FindNext() is giving error:error C2664: 'FindNext' : cannot convert parameter 1 from 'class MSExcel::Range'...
31 Jul 2013 by keerth516
HI, I am trying to send the mailmerge document as email.I am novice in this topic .could you please let me what went wrong and its correction to get the required result.Title.doc is my template and am using excel as datasource.I am trying to send email to mailmerge doc to emailid mentioned...
25 Jul 2013 by Sampath Lokuge
For that you have to use VS 2012.Check below mentioned links for more info.Creating Your First Application-Level Add-in for Outlookhttp://msdn.microsoft.com/en-us/library/vstudio/cc668191(v=vs.110).aspx[^]SOF...
8 Jul 2013 by Maciej Los
As Sergey has mentioned, the simplest way is to determine if process is 64-bit.Here is an example: How to know a process is 32-bit or 64-bit programmatically[^]
8 Jul 2013 by Rajan Maheshwari
To determine if office 2010 is 32 bit or 64 bit, we could check a registry key named Bitness. For more information, please refer to this article: http://technet.microsoft.com/en-us/library/ee681792.aspx[^].Also here is a resource with a same question you could refer to: Detect whether Office...
8 Jul 2013 by Sergey Alexandrovich Kryukov
Simply run it and find the process in Process Explorer, it will tell you.—SA
8 Jul 2013 by Pravinkarne.31
Hello,How to check my installed copy of MS office 2007 is of 32-Bit OR 64-Bit.Thanks,Pravin
20 Feb 2013 by koolprasad2003
I have Open a excel file using C#.NET (COM application) and trying to get it's HInstance but it gives me error on 64 bit EXCEL 2010.Here is my code objExelApp = new Excel.ApplicationClass(); objWorkbook = objExelApp.Workbooks.Add(misValue); iHinstance = objExelApp.Hinstance; //This...
11 Feb 2013 by Virendra_ec10
Hi Gurus,We have an Excel addin that is written in C++ and with this addin Excel crashes when we copy anything from the sheet and tried to paste by using any Paste options in Office 2010. Basically it crashes immediately once we try to hover the mouse over any of the Paste options of Office...
22 Nov 2012 by gwyder
HelloI've been trying to creating MS Access 2010 addin in VS 2010 Express in C# .NET 2.0. I implemented the IDTExtensibility2 interface, and created a function for addin registration, all code is shown below.AddIn:using Microsoft.Office.Core;using System;using...
1 Nov 2012 by Pasan Eeriyagama
This article focuses on a Very simple and Robust way to export Data to EXCEL
4 Oct 2012 by arshad alam
i am creating a word add-in in c#, i am creating a document, inserting a hyperlink and trying to bring it front. but newly created document does not come in front. it goes to back of the current window. Below are the code :Word.Document newNoteDoc = new Word.Document(); object...
4 Oct 2012 by arshad alam
0 down vote favorite i am creating a add-ins for Microsoft Word. i have a tree-view control where i am generating Folder, files and File's bookmarks in hierarchical structure.For this i am using these code :void GetTree(string strSearchPath) { ...
19 Jul 2012 by pramod.hegde
Merge slides from multiple presentations to one at a desired position
12 Jul 2012 by hornet_79
Solved it. Not the solution I would like most but at least it works. Above code just works fine if you use ".doc" instead of ".docx". So much for microsofts wonderful new xml based file formats... at least in that case ;-)It seems, that the OLEObjects in docx are not referenced. Instead they...
11 Jul 2012 by hornet_79
Hello,just tried to embed a word document (test0.docx) in another word document (test1.docx) as linked object. So far so easy. Now I took this document (test1.docx) and embedded it in the next one (test2.docx). Issue here is, that if I change test0.docx, save it and close it test2.docx isn't...
5 Apr 2012 by zero_226
I want change the content of outlook ribbon when customer click the ribbon, but I don't know how to do it.help, please, thanks every one.
8 Mar 2012 by Dagma D
In docx files there is a xml file called fontTable.xml and it contains the font information
20 Feb 2012 by Robert Hutch
Hi,you can easily C# edit Word file without generating a duplicate copy and ASP.NET export to Word with this C# / VB.NET Word library.This library doesn't have any dependency on Microsoft Word and doesn't use C# Word Automation which makes it ideal for ASP.NET server...
15 Feb 2012 by YKK Reddy
Hi All,After many attempts, i finally found out the solution. Thought of sharing with you guys.int iImageWidth = 0, iImageHeight = 0, iOffset = 10; using (Bitmap bitmap = new Bitmap(strImageFile)) { iImageHeight = bitmap.Height; ...
15 Feb 2012 by YKK Reddy
Hi All,I am using OpenXML SDK 2.0 and i am having a requirement that i need to insert an image into a particular cell and adjust the cell width and height (in other words corresponding Row Height and Column Width) according to the image Horizontal and Vertical Pixels.I am planning to use...
13 Feb 2012 by YKK Reddy
Hi,I have solved it myself. I am posting it here just in case anyone else needs.I modified the code for the "Drawing" class. The below code is mentioned:if (imageNumber == 1) { Drawing drawing = new Drawing() { Id = "rId" + drawingPartId.ToString() }; ...
12 Feb 2012 by YKK Reddy
Hi All,I have a requirement in my project to add multiple images on the fly. The images are dynamically obtained from another source (the image path is obtained) and i need to paste them at a particular location on the excel sheet.I am able to add single image successfully to spreadsheet...
12 Feb 2012 by YKK Reddy
Hi, For those who need this i am posting the solution also.I posted the same question in MSDN Microsoft forums and got the confirmation that it cannot be done using OpenXML. We need to use Interop services I am posting the link below. Go through the entire post if...
12 Feb 2012 by YKK Reddy
Hi, For those who need this i am posting the solution also.I posted the same question in MSDN Microsoft forums and got the solution. I am posting the link below. Go through the entire post if...
12 Feb 2012 by YKK Reddy
Hi,For those who need this i am posting the solution also.I posted the same question in MSDN Microsoft forums and got the solution.I am posting the link below. Go through the entire post if...
8 Feb 2012 by SayreCC
Hi,You can visit this link http://aspsnippets.com/Search.aspx?q=image , all sample regarding the image, saving, excel has on this site.Hope that one can help.Thank You.
8 Feb 2012 by YKK Reddy
Hi All,I am facing a problem in inserting the image in Sheet which has cell (that has comments inserted).I mean to say few cells in my Excel sheet have comments inserted. When i try to insert image using OpenXML SDK V2.0, the output excel file becomes unreadable.I have done the same...
7 Feb 2012 by YKK Reddy
The solution can be found at http://products.e-dbxml.net/openxml-spreadsheet/post/openxml-spreadsheet-copy-inser[^]There are few methods for getting cell row index, column index etc which has to be written separately.
7 Feb 2012 by YKK Reddy
private static Row CreateRow(Row refRow, SheetData sheetData, Row refRow1) { uint newRowIndex = 0; var newRow = new Row() { RowIndex = refRow.RowIndex.Value }; // Loop through all the rows in the worksheet with higher row // index...
31 Jan 2012 by RDBurmon
Read this two blog . You would definitely get some insighthttp://polymathprogrammer.com/2010/11/10/how-to-insert-multiple-images-in-excel-open-xml/[^]http://www.pcreview.co.uk/forums/can-you-anchor-image-cell-excel-t3493964.html[^]
30 Jan 2012 by Ganesan Senthilvel
Herez sample code:private static Cell InsertCellInWorksheet(string columnName, uint rowIndex, WorksheetPart worksheetPart) { Worksheet worksheet = worksheetPart.Worksheet; SheetData sheetData = worksheet.GetFirstChild(); string...
30 Jan 2012 by YKK Reddy
Hi,I am facing a problem in adding/inserting new/existing rows in between a excel sheet.Can anyone help me in achieving this ?For example, i need to copy Row# 10 and paste it after Row# 20.Kindly help.Thanks and Regards,YKK Reddy
30 Jan 2012 by YKK Reddy
Hi All,I have a requirement in my project that i need to copy few parts of my excel sheet and paste it in another part of the same sheet.Can anyone help me in achieving this ?For example, i need to copy rows 1 through 25 and paste them at Row number 40.Thanks and Regards,YKK Reddy
30 Jan 2012 by YKK Reddy
Hi,I need to add image at a particular cell location in an Excel sheet. I an using OpenXML approach for this. Can anyone suggest me how to achieve this ?For example, i need to put an image at cell "D5".Thanks and Regards,YKK Reddy
26 Jan 2012 by YKK Reddy
Hi,Can we convert office documents (Word/Excel) to PDF/XPS using OpenXML.I am aware of the fact that we can accomplish the above using Microsoft Interop assemblies but the impending factor is that the conversion is very slow.If i provide big/huge documents as input, it is taking lot of...
18 Jan 2012 by Dagma D
In Doc file the fonts are stored in table stream.
15 Jan 2012 by Dagma D
This is the logical structure of a .doc file..MyDocument.doc1Table*CompObjWord Document*SummaryInformation*DocumentSummaryInformationHere Text part is stored in word document stream..Now my question is where is the font information of a .doc file stored???& also where is...
1 Jan 2012 by Espen Harlinn
Have a look at this:http://www.softwaregarden.com/products/wikicalc/[^]Best regardsEspen Harlinn