Skip to content

Instantly share code, notes, and snippets.

View JamesIgoe's full-sized avatar

James J. Igoe JamesIgoe

View GitHub Profile
@JamesIgoe
JamesIgoe / StatusUpdateForOutlook.js
Last active September 4, 2018 16:59
Outlook helper function to add a status message to the info bar via Office API, written in JavaScript
function statusUpdate (icon, text) {
Office.context.mailbox.item.notificationMessages.replaceAsync("status", {
type: "informationalMessage",
icon: icon,
message: text,
persistent: false
});
}
@JamesIgoe
JamesIgoe / SettingsManager.js
Last active September 4, 2018 17:00
Settings Manager for Outlook Add-in, , written in JavaScript - MS code converted into reusable
var settingsManager = (function () {
"use strict";
var settingsManager = {};
var _settings;
settingsManager.initialize = function () {
//global for custom property
_settings = Office.context.roamingSettings;
@JamesIgoe
JamesIgoe / CellsetToPivotTable.cs
Created September 4, 2018 17:05
The code is less than ideal, and is bit dirty, but turns MDX-based cellsets into pivottables: - Uses selected pivot to extract MDX and connection (you can replace with your server-side stuff) - Uses your GetDataTable() to transform cellset to data table - Uses found code to turn datatable into ADODB recordset - Creates pivotchache and then pivot…
The code is less than ideal, and is bit dirty, but turns MDX-based cellsets into pivottables:
- Uses selected pivot to extract MDX and connection (you can replace with your server-side stuff)
- Uses your GetDataTable() to transform cellset to data table
- Uses found code to turn datatable into ADODB recordset
- Creates pivotchache and then pivottable
private void InsertPivotAsRecordset_Click(object sender, RibbonControlEventArgs e)
{
//down and dirty----
@JamesIgoe
JamesIgoe / EulerLib.fs
Created September 4, 2018 17:07
Various Number Functions (F#) A collection of basic mathematical functions written in F# as part of my learning via Project Euler. This module has functions for creating arrays or calculating values for the following: Primes Factorials Narcissism Collatz Sequence Terra Sequence Fibonnaci Distinct Primes Random Numbers and Arrays
#light
module EulerLib
open Stat
open Print
open System.Numerics
open System
open System.Collections
let public getPrimes max =
@JamesIgoe
JamesIgoe / PowerRelatedCode.cs
Created September 4, 2018 17:08
Power Code - Handle Sleep & Suspension Excel C# code to reload an Excel add-in, although this should work for any office product, upon waking from suspend on Windows 7
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
SystemEvents.PowerModeChanged += OnPowerChange;
}
void OnPowerChange(Object sender, PowerModeChangedEventArgs e)
{
switch (e.Mode)
{
case PowerModes.Resume:
@JamesIgoe
JamesIgoe / SecondaryAxisAlignment.cs
Created September 4, 2018 17:10
Excel Charting - Align Secondary Axis with C# The code for this is linked below, and the general algorithm used for aligning a chart's secondary axis with the primary axis: Get primary divisors Get upper and lower bounds of secondary Get larger ABS(max) or ABS(min) Multiply (max/min) divisor by numbers (1,2,5,10,20,25,30) to find the first multi…
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IExcel = Microsoft.Office.Interop.Excel;
namespace AccountHoldingsAddIn.Helpers
{
public class Charting
{
@JamesIgoe
JamesIgoe / FacadePattern.cs
Created September 4, 2018 17:13
Combine the Facade pattern with the Publisher (Observer) pattern. The facade, based on ISubscriberFacade, encapsulates all the methods required to work with the Windows Communication Foundation (WCF) service , handling threading, delegate creation, and asynchronous callbacks internally, so that that the clients only need to create the object. I …
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Net;
using System.Reflection;
using System.ServiceModel;
using System.Threading;
@JamesIgoe
JamesIgoe / CustomXmlParts.bas
Created September 4, 2018 17:14
This code shows the basics of working with CustomXmlPart of the Office 2007 and greater environment. It is a way to store complex information within workbooks. In this example, I create a type, and the create XML to stores the type, and then either set, or retrieve the XML.
Option Explicit
Type Execution
SheetCodeName As String
StoredProcedure As String
Date As String
Portfolios As String
Fields As String
End Type
<!-- Rules-based detected entity for right click on spam -->
<ExtensionPoint xsi:type="DetectedEntity">
<Label resid="sendSpamButtonLabel" />
<SourceLocation resid="sendSpamTaskPaneUrl" />
<Rule xsi:type="RuleCollection" Mode="And">
<Rule xsi:type="ItemIs" ItemType="Message" Highlight="All" />
<Rule xsi:type="ItemHasRegularExpressionMatch" RegExName="subjectWithExternal" RegExValue="(\[EXTERNAL\])" PropertyName="Subject" Highlight="All" />
<Rule xsi:type="ItemHasRegularExpressionMatch" RegExName="allText" RegExValue=".*" PropertyName="BodyAsPlaintext" Highlight="All" />
</Rule>
</ExtensionPoint>
Public Class DateHelpers
Public Shared Function GetNextWeekday(ByVal start As DateTime, ByVal day As DayOfWeek) As Integer
Return (CInt(day) - CInt(start.DayOfWeek) + 7) Mod 7
End Function
Public Shared Function DateWeek(item As Date) As Integer