Paradox Community

Items in pnews.paradox-programming

Subject:Re: Cut and Paste - Table into Excel -
Date:Tue, 31 Jul 2018 09:41:24 +0200
From:"modridirkac" <jure.zorko@gmail.com>
Newsgroups:pnews.paradox-programming
This code works for me.
You must have something in the clipboard, before calling this script.
You must also have an xls file in tem folder, to open it.

This code opens OLE t oexcel, loads file (c:\temp\excel.xlsx) and pasts to 
cells B5:C8
and shows final result in excel.

const
    ; Excel coord. types
    xlA1   = 1                ; A1
   xlR1C1 = - 4150        ; R1C1
endConst

method run(var eventInfo Event)
; paste from clipboard to excel
var excel OleAuto
     Workbooks, sel  OLEAuto
endVar
    ; start excel
    Excel.open("Excel.Application")
    Excel.DisplayAlerts=false

    ; open file
    Workbooks = Excel.Workbooks
    if WorkBooks.count>0 then return endif
    Workbooks.invoke("Open", "c:\\temp\\excel.xlsx")

    ; mark your range
   s = Excel.convertFormula("B5:C8", xlA1, xlR1C1, True)
   Excel.goto(s)
   sel = Excel.Selection

   ; paste from clipboard to that selection
   sel.Invoke("PasteSpecial")

   ; show the result
    Excel.visible=true
endMethod



Copyright © 2004 thedbcommunity.com