Paradox Community

Items in pnews.paradox-programming

Subject:Re: Cut and Paste - Table into Excel -
Date:Tue, 31 Jul 2018 22:42:28 +1000
From:Robert MacMillan <macfam@bigpond.net.au>
Newsgroups:pnews.paradox-programming
Thanks heaps modridirkac.

This is one of those really frustrating Paradox and in this case OLE 
issues that once solved will remain solved forever. In the meantime much 
frustration.

So if I use sel.Invoke("PasteSpecial")

It does indeed paste. However it Pastes everything on the clipboard 
including the stuff that is not visible so all the horizontal and 
vertical bars one sees in a table so those are being stored on the 
Clipboard but are not visible.

If I use sel.Invoke("Paste") ....... and am watching what is going on 
with the spreadsheet then the focus goes to the Paste Button which then 
waits for interaction. And will paste. So the focus is in the right spot 
in the spreadsheet. One can continue with the Paste using the down arrow 
on the Paste Button or Ctrl+V also pastes correctly.

What I cant seem to do and I must be stupid because if "PasteSpecial" 
works then there must be a way to emulate the Ctrl+V command but I cant 
figure it out. Tried absolutely everything I can think of so far.

Another one of those things which should be obvious but is not.

Anyway. Thanks for the help and it was a huge help because it gets me to 
where all I have to do is figure what I am missing.

Robert

On 31/07/2018 5:41 PM, modridirkac wrote:
> 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