Skip to content

Instantly share code, notes, and snippets.

@aptavout aptavout/auto-pivot
Created Mar 12, 2014

Embed
What would you like to do?
Programmatic PivotTable using the VBA you already wrote (or recorded)
Const xlHTMLStatic = 0
Set args = Wscript.Arguments
Set objShell = CreateObject("Wscript.Shell")
htmPath = Wscript.Arguments.Item(0)
personalWb = objShell.ExpandEnvironmentStrings("%PERSONALWB%")
Set oXl = CreateObject("Excel.Application")
Set oPersonal = oXl.Workbooks.Open(personalWb)
oXl.Run oPersonal.Name & "!Module1.HelloWorld","hi"
Set oLogWb = oXl.ActiveWorkbook
oLogWb.PublishObjects.Add(4, htmPath & "\outlook-body.htm", "Sheet1", _
oLogWb.Sheets("Sheet1").Range("A:AE").Address, xlHTMLStatic).Publish (True)
oXl.ActiveWorkbook.Close False
oPersonal.Close
oXl.Quit
Set oLogWb = Nothing
Set oPersonal = Nothing
Set oXl = Nothing
Set objShell = Nothing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.