Skip to content

Instantly share code, notes, and snippets.

@mathias-brandewinder
Created January 21, 2013 00:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mathias-brandewinder/4582881 to your computer and use it in GitHub Desktop.
Save mathias-brandewinder/4582881 to your computer and use it in GitHub Desktop.
Attach to running Excel instance in F# and write to a Worksheet
#r "office.dll"
#r "Microsoft.Office.Interop.Excel"
open Microsoft.Office.Interop.Excel
open System.Runtime.InteropServices
let xl = Marshal.GetActiveObject("Excel.Application") :?> Microsoft.Office.Interop.Excel.Application
let wbs = xl.Workbooks
let wb = wbs.[1]
let sh = wb.Worksheets.[1] :?> Worksheet
sh.Cells.[1,1] <- "Hello from F#!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment