working on it ...

Filters

Explore Public Snippets

Sort by

Found 16k snippets matching: office

    public by lbottaro  463517  0  7  0

    Excel function to calculate the average of positive data in range

    This excel function calculate the average of a specific range of cells, regarding only positive values. Zero or less than zero value won't be used in average calculation. The italian version of this snippet can be used as well on OpenOffice 3.
    =SUMIF(B2:B6;">0")/MAX(COUNTIF(B2:B6;">0");1)
    
    # Italian version
    =SOMMA.SE(B2:B6;">0")/MAX(CONTA.SE(B2:B6;">0");1)

    public by lbottaro  22124  137  9  3

    How to programmatically create a Microsoft Word document in csharp

    This code shows how to simply create a doc using csharp and Microsoft Office Word library. 1) You need to add a reference to Microsoft.Office.Interop library in your project solution. 2) Add the following line to the end of the list of using directives: using Word = Microsoft.Office.Interop.Word; using System.Reflection; 3) Now you are
    private void button1_Click(object sender, EventArgs e)
            {
              object oMissing = System.Reflection.Missing.Value;
               object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */
    
               //Start Word and create a new document.
               Word._Application oWord;
               Word._Document oDoc;
               oWord = new Word.Application();
               oWord.Visible = true;
               oDoc = oWord.Documents.Add(ref oMissing, ref oMissing,
                   ref oMissing, ref oMissing);
    
               //Insert a paragraph at the beginning of the document.
               Word.Paragraph oPara1;
               oPara1 = oDoc.Content.Paragraphs.Add(ref oMissing);
               oPara1.Range.Text = "Heading 1";
               oPara1.Range.Font.Bold = 1;
               oPara1.Format.SpaceAfter = 24;    //24 pt spacing after paragraph.
               oPara1.Range.InsertParagraphAfter();
    
               //Insert a paragraph at the end of the document.
               Word.Paragraph oPara2;
               object oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
               oPara2 = oDoc.Content.Paragraphs.Add(ref oRng);
               oPara2.Range.Text = "Heading 2";
               oPara2.Format.SpaceAfter = 6;
               oPara2.Range.InsertParagraphAfter();
    
               //Insert another paragraph.
               Word.Paragraph oPara3;
               oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
               oPara3 = oDoc.Content.Paragraphs.Add(ref oRng);
               oPara3.Range.Text = "This is a sentence of normal text. Now here is a table:";
               oPara3.Range.Font.Bold = 0;
               oPara3.Format.SpaceAfter = 24;
               oPara3.Range.InsertParagraphAfter();
    
               //Insert a 3 x 5 table, fill it with data, and make the first row
               //bold and italic.
               Word.Table oTable;
               Word.Range wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
               oTable = oDoc.Tables.Add(wrdRng, 3, 5, ref oMissing, ref oMissing);
               oTable.Range.ParagraphFormat.SpaceAfter = 6;
               int r, c;
               string strText;
               for (r = 1; r <= 3; r++)
                   for (c = 1; c <= 5; c++)
                   {
                       strText = "r" + r + "c" + c;
                       oTable.Cell(r, c).Range.Text = strText;
                   }
               oTable.Rows[1].Range.Font.Bold = 1;
               oTable.Rows[1].Range.Font.Italic = 1;
    
               //Add some text after the table.
               Word.Paragraph oPara4;
               oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
               oPara4 = oDoc.Content.Paragraphs.Add(ref oRng);
               oPara4.Range.InsertParagraphBefore();
               oPara4.Range.Text = "And here's another table:";
               oPara4.Format.SpaceAfter = 24;
               oPara4.Range.InsertParagraphAfter();
    
               //Insert a 5 x 2 table, fill it with data, and change the column widths.
               wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
               oTable = oDoc.Tables.Add(wrdRng, 5, 2, ref oMissing, ref oMissing);
               oTable.Range.ParagraphFormat.SpaceAfter = 6;
               for (r = 1; r <= 5; r++)
                   for (c = 1; c <= 2; c++)
                   {
                       strText = "r" + r + "c" + c;
                       oTable.Cell(r, c).Range.Text = strText;
                   }
               oTable.Columns[1].Width = oWord.InchesToPoints(2); //Change width of columns 1 & 2
               oTable.Columns[2].Width = oWord.InchesToPoints(3);
    
               //Keep inserting text. When you get to 7 inches from top of the
               //document, insert a hard page break.
               object oPos;
               double dPos = oWord.InchesToPoints(7);
               oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range.InsertParagraphAfter();
               do
               {
                   wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
                   wrdRng.ParagraphFormat.SpaceAfter = 6;
                   wrdRng.InsertAfter("A line of text");
                   wrdRng.InsertParagraphAfter();
                   oPos = wrdRng.get_Information
                                  (Word.WdInformation.wdVerticalPositionRelativeToPage);
               }
               while (dPos >= Convert.ToDouble(oPos));
               object oCollapseEnd = Word.WdCollapseDirection.wdCollapseEnd;
               object oPageBreak = Word.WdBreakType.wdPageBreak;
               wrdRng.Collapse(ref oCollapseEnd);
               wrdRng.InsertBreak(ref oPageBreak);
               wrdRng.Collapse(ref oCollapseEnd);
               wrdRng.InsertAfter("We're now on page 2. Here's my chart:");
               wrdRng.InsertParagraphAfter();
    
               //Insert a chart.
               Word.InlineShape oShape;
               object oClassType = "MSGraph.Chart.8";
               wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
               oShape = wrdRng.InlineShapes.AddOLEObject(ref oClassType, ref oMissing,
                   ref oMissing, ref oMissing, ref oMissing,
                   ref oMissing, ref oMissing, ref oMissing);
    
               //Demonstrate use of late bound oChart and oChartApp objects to
               //manipulate the chart object with MSGraph.
               object oChart;
               object oChartApp;
               oChart = oShape.OLEFormat.Object;
               oChartApp = oChart.GetType().InvokeMember("Application",
                   BindingFlags.GetProperty, null, oChart, null);
    
               //Change the chart type to Line.
               object[] Parameters = new Object[1];
               Parameters[0] = 4; //xlLine = 4
               oChart.GetType().InvokeMember("ChartType", BindingFlags.SetProperty,
                   null, oChart, Parameters);
    
               //Update the chart image and quit MSGraph.
               oChartApp.GetType().InvokeMember("Update",
                   BindingFlags.InvokeMethod, null, oChartApp, null);
               oChartApp.GetType().InvokeMember("Quit",
                   BindingFlags.InvokeMethod, null, oChartApp, null);
               //... If desired, you can proceed from here using the Microsoft Graph 
               //Object model on the oChart and oChartApp objects to make additional
               //changes to the chart.
    
               //Set the width of the chart.
               oShape.Width = oWord.InchesToPoints(6.25f);
               oShape.Height = oWord.InchesToPoints(3.57f);
    
               //Add text after the chart.
               wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
               wrdRng.InsertParagraphAfter();
               wrdRng.InsertAfter("THE END.");
    
               //Close this form.
               this.Close();
    }
    

    public by Warrenmiller  1193  0  5  0

    Office 365 support - +1-800-8268068

    Office 365 products and tools provide its user, reliability and a wonderful environment to communicate through internet. But sometime issues come during using the office 365 application. If you face any problem while using office 365 products, now do not worry for your issues with office 365.Our office 365 support executives will help from your any kind of problem. For more information please visit the url given below.
    http://www.microsoftoutlookoffice365.com/outlook-365-support.html
    

    public by paulsimmons  1110  0  5  0

    Magento Follow Up Emails Extension

    Magento Follow Up Email is a complete extension developed by FMEAddons that allows store owners to integrate and advance email marketing system in their online store based on Magento. With the help of this powerful extension, they can send emails after occurring of different events such as new order completion, Cart abandonment, Birthday, Christmas
    // Enter here the actual content of the snippet.                        

    public by paulsimmons  351  7  5  0

    Custom Registration Form Wordpress

    WooCommerce doesn't allow you to edit registration form? Try, Custom registration form WordPress addon which will enable you to add the fields and edit registration page. With this addon, you can get any type of information from your website users on registration. This addon will help you to understand the likeness of your users and you can make yo
    // Enter here the actual content of the snippet.                                    

    public by paulsimmons  656  0  4  0

    FMEAddons - Magento VAT Add-on

    You can let your customers buy products from you without tax by using Magento VAT extension by FMEAddons. This is a most important add-on for merchants who sell products outside the Europe, and in such countries where free trades agreements are prevailed by the Governments. Merchants can also export the VAT invoices of any duration by using filters
    // Enter here the actual content of the snippet.            

    public by msdn  1489  0  6  0

    ExportContacts: Export all contacts into the CSV file from Office 365 Exchange Online.

    Export all contacts into the CSV file from Office 365 Exchange Online.
    using System;
    using System.Collections.Generic;
    using Microsoft.Exchange.WebServices.Data;
    using System.Net;
    using System.Net.Security;
    using System.Security.Cryptography.X509Certificates;
    using System.IO;
    
    /// <summary>
    /// Export all contacts into the CSV file from Office 365 Exchange Online.
    /// </summary>
    private static void ExportContacts(ExchangeService service)
    {
        // Get the properties we need to write.
        PropertySet propertySet = new PropertySet();
        Dictionary<PropertyDefinitionBase, String> schemaList = 
            ContactsHelper.GetSchemaList();
        propertySet.AddRange(schemaList.Keys);
    
        List<Item> results = GetItems(service, null, WellKnownFolderName.Contacts, 
            propertySet);
        String path = GetFolderPath();
        String filePath = Path.Combine(path, "contacts.csv");
    
        using (StreamWriter writer = new StreamWriter(filePath))
        {
            Boolean firstCell = true;
    
            // Write the head title
            foreach (PropertyDefinitionBase head in schemaList.Keys)
            {
                if (!firstCell)
                {
                    writer.Write(",");
                }
                else
                {
                    firstCell = false;
                }
    
                writer.Write("\"{0}\"",schemaList[head]);
            }
            writer.WriteLine();
            firstCell = true;
    
            // Write the contact.
            foreach (Item item in results)
            {
                Contact contact = item as Contact;
    
                foreach (PropertyDefinitionBase proerty in schemaList.Keys)
                {
                    if (!firstCell)
                    {
                        writer.Write(",");
                    }
                    else
                    {
                        firstCell = false;
                    }
    
                    ContactsHelper.WriteContacts(writer, proerty, contact);
                }
    
                writer.WriteLine();
                firstCell = true;
            }
        }
    
        Console.WriteLine();
        Console.WriteLine("Export the contacts to the file:{0}",filePath); 
    }

    public by msdn  1255  0  7  0

    Compact: Compact an Office document structured storage.

    Compact an Office document structured storage. Full path to the document
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Text;
    using System.Runtime.InteropServices;
    using ComTypes = System.Runtime.InteropServices.ComTypes;
    using System.Windows.Forms;
    using System.Windows.Forms.Design;
    using System.Runtime.InteropServices.ComTypes;
    using System.ComponentModel;
    
    /// <summary>
    /// Compact an Office document structured storage.
    /// </summary>
    /// <param name="documentPath">Full path to the document</param>
    public static void Compact(string documentPath)
    {
        int hr = 0;
        string tempFilename = null;
        Guid documentCLSID;
        IStorage documentStorage = null;
        IStorage tempStorage = null;
    
        if (String.IsNullOrEmpty(documentPath))
            throw new ArgumentNullException("documentPath");
    
        if (!File.Exists(documentPath))
            throw new FileNotFoundException();
    
        try
        {
            //  Open existing document.
            //
            hr = NativeMethods.StgOpenStorage(documentPath,
                    null,
                    STGM.STGM_READ | STGM.STGM_SHARE_EXCLUSIVE,
                    IntPtr.Zero,
                    0,
                    out documentStorage
                    );
            Marshal.ThrowExceptionForHR(hr);
    
            ComTypes.STATSTG statstg = new ComTypes.STATSTG();
            hr = documentStorage.Stat(out statstg, 0);
            Marshal.ThrowExceptionForHR(hr);
            documentCLSID = statstg.clsid;
    
            //  Open temp file and copy existing storage to it.
            //  This will automatically get deleted when the storage is released.
            tempFilename = Path.GetTempFileName();
            hr = NativeMethods.StgCreateDocfile(tempFilename,
                    STGM.STGM_CREATE | STGM.STGM_READWRITE | STGM.STGM_SHARE_EXCLUSIVE | STGM.STGM_DELETEONRELEASE,
                    0,
                    out tempStorage
                    );
            Marshal.ThrowExceptionForHR(hr);
    
            hr = documentStorage.CopyTo(0, null, IntPtr.Zero, tempStorage);
            Marshal.ThrowExceptionForHR(hr);
    
            //  Force CLR to release the document IStorage so it can be reopened.
            Marshal.ReleaseComObject(documentStorage);
            documentStorage = null;
    
            //  A RACE CONDITION COULD OCCUR HERE
            //  
            //  The documentStorage is released but we have yet to reopen the document so
            //  other threads or processes could open it. This gives rise to two cases:
            //
            //  1) The file is opened and remains open. In which case the call to StgCreateDocfile 
            //  will fail, because it is unable to open exclusively.
            //
            //  2) The other thread/process opens, writes and closes the file. In this case any
            //  changes made by this thread/process will be overwritten and data will be lost.
    
            //  Create new storage over old document and copy storage back
            hr = NativeMethods.StgCreateDocfile(documentPath,
                    STGM.STGM_CREATE | STGM.STGM_READWRITE | STGM.STGM_SHARE_EXCLUSIVE,
                    0,
                    out documentStorage
                    );
            Marshal.ThrowExceptionForHR(hr);
    
            hr = documentStorage.SetClass(ref documentCLSID);
            Marshal.ThrowExceptionForHR(hr);
    
            hr = tempStorage.CopyTo(0, null, IntPtr.Zero, documentStorage);
            Marshal.ThrowExceptionForHR(hr);
        }
        finally
        {
            if (documentStorage != null)
            {
                Marshal.ReleaseComObject(documentStorage);
                documentStorage = null;
            }
            if (tempStorage != null)
            {
                Marshal.ReleaseComObject(tempStorage);
                tempStorage = null;
            }
        }
    }

    public by msdn  1191  0  7  0

    CreateOffice: Create a new Office object.

    Create a new Office object. Initial value of OfficeId. Initial value of CalendarId.
    /// <summary>
    /// Create a new Office object.
    /// </summary>
    /// <param name="officeId">Initial value of OfficeId.</param>
    /// <param name="calendarId">Initial value of CalendarId.</param>
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
    public static Office CreateOffice(int officeId, int calendarId)
    {
        Office office = new Office();
        office.OfficeId = officeId;
        office.CalendarId = calendarId;
        return office;
    }

    public by msdn  1596  0  6  0

    CreateTeam: Create a new Team object.

    Create a new Team object. Initial value of TeamId. Initial value of ManagerId. Initial value of OfficeId.
    /// <summary>
    /// Create a new Team object.
    /// </summary>
    /// <param name="teamId">Initial value of TeamId.</param>
    /// <param name="managerId">Initial value of ManagerId.</param>
    /// <param name="officeId">Initial value of OfficeId.</param>
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Services.Design", "1.0.0")]
    public static Team CreateTeam(int teamId, int managerId, int officeId)
    {
        Team team = new Team();
        team.TeamId = teamId;
        team.ManagerId = managerId;
        team.OfficeId = officeId;
        return team;
    }
    • Public Snippets
    • Channels Snippets