Click here to Skip to main content
15,899,026 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 

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...
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...
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...
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...
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...
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); ...
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) ...
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) { ...
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) ...
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...
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
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,...
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...
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) { ...
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...
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...
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...
14 Dec 2015 by bradyguy
Don't send your mail out using the wrong account
30 Mar 2016 by ChadFolden1
Extract Microsoft Outlook messages from a PST into a folder structure
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...
18 Jan 2012 by Dagma D
In Doc file the fonts are stored in table stream.
8 Mar 2012 by Dagma D
In docx files there is a xml file called fontTable.xml and it contains the font information
3 Mar 2017 by Dracula
Run all rules for all accounts on all messages; also useful as Outlook Rule debug tool.
27 Sep 2011 by emrea
Hi all,I'm trying to write a replacement function in C# for Corel WordPerfect;WordPerfect.PerfectScript objWordPerfect = new...
1 Jan 2012 by Espen Harlinn
Have a look at this:http://www.softwaregarden.com/products/wikicalc/[^]Best regardsEspen Harlinn
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...
4 Mar 2018 by Gaston Verelst
How to create a Visio Add-in in VS2017
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...
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...
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 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...
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 ...
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...
14 Jun 2011 by koolprasad2003
You are trying to open your word file in ReadOnly mode on save button clickwhy so ?
6 Sep 2011 by koolprasad2003
IIS7 on Win Server 2008 ?Create a new "Desktop" directory inside of "C:\Windows\SysWOW64\config\systemprofile\" and give access Modify of NetworkServices and User group.
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...
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).
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
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...
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[^]
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)[^]
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).
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[^]
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,...
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...
28 Aug 2011 by Md. Marufuzzaman
How to add a menu item in Microsoft Office Word 7/10 application context menu
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...
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...
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...
14 Jun 2011 by Member 7949965
I am editing a word document in the browser itself. Every time I press the save button it will generate a duplicate copy. How can I avoid this duplicate copy in asp.net?using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.IO;using...
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'...
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 !=...
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))...
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[^]
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 =...
17 Jul 2011 by natsuyaki
I'm trying to resize the image in an existing Word document.I set InlineShape.Width and InlineShape.Height, call Field.Update() to apply the changes, and then save the doc.But it seems nothing happened to the images.Code:foreach (Field f in doc.Fields) { if (f.LinkFormat.Type...
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...
1 Nov 2012 by Pasan Eeriyagama
This article focuses on a Very simple and Robust way to export Data to EXCEL
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...
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...
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)...
19 Jul 2012 by pramod.hegde
Merge slides from multiple presentations to one at a desired position
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
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...
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...
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...
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...
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[^]
6 Jun 2017 by Richard MacCutchan
See How to hide ribbon display in excel using C#[^].
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.
10 Jul 2017 by Richard MacCutchan
SparklineGroups excel interop - Google Search[^]
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...
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...
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
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...
6 Sep 2011 by saraghasemi
HiWe have a ASP.NET app that uses the Word 2007 to open a file and publish it as a PDF. This works fine when we run it in Visual Studio 2008 in Debug, but when we run it as a normal website we get the following error:System.UnauthorizedAccessException: Retrieving the COM class factory for...
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 Jul 2013 by Sergey Alexandrovich Kryukov
Simply run it and find the process in Process Explorer, it will tell you.—SA
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...
30 Aug 2017 by simonp_ca
Use Excel worksheet's cells as pixels to render real image (for fun and experiment)
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.
19 Jul 2011 by SivakumarPVP
Hi,We are performing office automation(opening .doc,.wpd files and saving them as .html) in console application using Microsoft.Office.Interop.Word in C#. When WPD file with graphic content is processed using the application,“WordPerfect 6.x - 7.0 Conversion" window is getting displayed...
2 Jul 2016 by Six Hat Solutions
Easily Send Emails From Your Microsoft Applications Using VBA and the SendGrid API
27 Sep 2011 by Slacker007
You may want to check this out if you haven't already.Wordperfect Community Forum[^]
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.
25 Dec 2015 by Tim Cadenbach
License Verification Attribute for MVC and Office-Addins
4 Dec 2011 by toby31
I am currently working on an InfoPath ribbon using VSTO. I am using components that change at run time taking into consideration the content of the document. The problem is that when i open multiple documents the information in the ribbon is the same in every documen.From what i read the...
4 Dec 2011 by toby31
Found it:private void ThisAddIn_Startup(object sender, System.EventArgs e){ InfoPath._Application3 iApplication = (InfoPath._Application3)this.Application; events = (InfoPath.ApplicationEvents)iApplication.Events; events.WindowActivate += new...
1 Jan 2012 by usernametakenalready
Hi,Is there any idea about creating a Web application where we can able to show data in spreadsheet and do all the same manipulations those are possible in spreadsheet programs (at least basic manipulations) ?Thanks in Advance.
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...
6 Sep 2011 by Wendelius
Could it be that the account running the code does not have necessary privileges for COM operations. Use dcomcnfg.exe to check the necessary privileges.Also have a look at this conversation: http://www.codeguru.com/forum/printthread.php?t=383912&page=3&pp=15[^]
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;
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 ???
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...
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
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 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