Paradox Community

Items in pnews.paradox-programming

Subject:Re: Cut and Paste - Table into Excel -
Date:Wed, 15 Aug 2018 10:31:07 +1000
From:Robert MacMillan <macfam@bigpond.net.au>
Newsgroups:pnews.paradox-programming
Hello Modridirkac and others.

the VBA Code to do what I need is - dont worry about the naming I have 
not called it anything in particular -

"Sub Macro1()
'
' Macro1 Macro
'

'
     Range("A2").Select
     ActiveSheet.PasteSpecial Format:="Text", Link:=False, DisplayAsIcon:= _
         False
End Sub"

So when I send

sel.Invoke("PasteSpecial", "Format:=\"Text\"", "Link:=False", 
"DisplayAsIcon:= False")

or any of the variations I have tried I get I get a Paradox Error 
message box of "PasteSpecial Method of range class Failed"

So I am getting very close. A Paste Special is obviously being attempted 
but I dont have the syntax to pass the parameters correctly.

All suggestions appreciated.

Thanks

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