WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with Excel
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Load WIL Array into Excel


;/////////////////////////////////////
;Cute Excel Trick with WB Arrays
;
;Stan Littlefield, August 20, 2005
;/////////////////////////////////////

;set up WB array
aR = ArrDimension(5)
aR[0] = "Name"
aR[1] = "Address"
aR[2] = "City"
aR[3] = "State"
aR[4] = "Zip"

;create empty workbook
oXL = CreateObject("Excel.Application")
If oXL == 0 Then Exit

oXL.Visible          = 1
oXL.ScreenUpdating   = 1
oXL.UserControl      = 1
oXL.DisplayAlerts    = 0
xlWBATWorksheet = -4167
oXL.WorkBooks.Add(xlWBATWorksheet)   ;simple way to add only 1 worksheet
oWS=oXL.ActiveWorkBook.Worksheets(1)
oWS.Activate()

;arrange array values horizontal
oWS.Range("A1:E1").Value = aR

;then vertical
oWS.Range("A3:A7").Value = oXL.WorkSheetFunction.Transpose(aR)

oWS=0
oXL=0

Exit
;//////////////////////////////////////////////////////////////////////////////////

Article ID:   W17159
File Created: 2007:07:03:14:28:32
Last Updated: 2007:07:03:14:28:32