Rod Caldwell
2008-11-03 12:07:40 UTC
Hi all,
I\'ve found the bug I was describing earlier where the PASTE function in Excel refused to work. You must open Excel first before you load the data into the clipboard!
The modified code is :
function EXCELBTN_onClick
local oExcel, i, nRow, f
_app.l = true // Excel
// Create instances of our variables so we can use
// the assignment (:=) operator from here on out.
store 0 to oExcel, i, nRow
cText = "" // initialize our string variable
if form.OUTSTANDING.value = true
Class::OUTSTANDINGwk(False) // loads to text into cText
else // form.ALLOUTSTANDING.value = true
Class::OUTSTANDINGwk(True)
endif
// now we start Excel
oExcel := new oleAutoclient("excel.application")
oExcel.visible = true
// create a new workbook
oExcel.workbooks.add()
// since the field and record separators are embedded
// all we need to do is select the top left cell.
// of course you could stick column headings in here,
// but we won't bother in this example.
oExcel.ActiveSheet.cells( 1,1 ).select()
// now add the text into the clipboard
// THIS MUST BE DONE AFTER YOU OPEN EXCEL
set procedure to clipbord.cc additive
_app.Clip = new TextClipboard() // create our clipboard object
_app.Clip.SetClipboardText( cText ) // place our string
// now just call Excel's paste method
oExcel.ActiveSheet.paste()
// and size the columns to fit
oExcel.ActiveSheet.Columns.AutoFit()
// now we select A1 to un-select the range
oExcel.ActiveSheet.Range("A1").Select()
form.close()
return
I\'ve found the bug I was describing earlier where the PASTE function in Excel refused to work. You must open Excel first before you load the data into the clipboard!
The modified code is :
function EXCELBTN_onClick
local oExcel, i, nRow, f
_app.l = true // Excel
// Create instances of our variables so we can use
// the assignment (:=) operator from here on out.
store 0 to oExcel, i, nRow
cText = "" // initialize our string variable
if form.OUTSTANDING.value = true
Class::OUTSTANDINGwk(False) // loads to text into cText
else // form.ALLOUTSTANDING.value = true
Class::OUTSTANDINGwk(True)
endif
// now we start Excel
oExcel := new oleAutoclient("excel.application")
oExcel.visible = true
// create a new workbook
oExcel.workbooks.add()
// since the field and record separators are embedded
// all we need to do is select the top left cell.
// of course you could stick column headings in here,
// but we won't bother in this example.
oExcel.ActiveSheet.cells( 1,1 ).select()
// now add the text into the clipboard
// THIS MUST BE DONE AFTER YOU OPEN EXCEL
set procedure to clipbord.cc additive
_app.Clip = new TextClipboard() // create our clipboard object
_app.Clip.SetClipboardText( cText ) // place our string
// now just call Excel's paste method
oExcel.ActiveSheet.paste()
// and size the columns to fit
oExcel.ActiveSheet.Columns.AutoFit()
// now we select A1 to un-select the range
oExcel.ActiveSheet.Range("A1").Select()
form.close()
return