Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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