COMatePLUS: Copy sheet and paste it in my workbook
Posted: Thu Oct 15, 2009 7:59 pm
Hi,
i want to copy my actual sheet into my workbook to get a 100% copy of a my sheet, but it looks like that this function "Sheets\copy" of the OWC11 doesn't run correct. So in the past i helped me with the following workarround:
But why does the function:
not work? You can see more information about this function in the OWC11 help file under "Copy Method".
i want to copy my actual sheet into my workbook to get a 100% copy of a my sheet, but it looks like that this function "Sheets\copy" of the OWC11 doesn't run correct. So in the past i helped me with the following workarround:
Code: Select all
IncludePath "..\"
XIncludeFile "COMatePLUS.pbi"
ExcelObject.COMateObject
ExcelObject1.COMateObject
obSheet.COMateObject
If OpenWindow(0,#PB_Ignore,#PB_Ignore,800,400,"COMate: OWC11.Spreadsheet-Demo",#PB_Window_Invisible|#PB_Window_SystemMenu)
ExcelObject=COMate_CreateActiveXControl(0,50,800,350,"OWC11.Spreadsheet")
If ExcelObject
ExcelObject\SetProperty("Cells(1,1) = 'Özgür'")
ExcelObject\SetProperty("Cells(1,2) = 'Levent'")
ExcelObject\SetProperty("Cells(2,1) = 10")
ExcelObject\SetProperty("Cells(2,2) = 20")
ExcelObject\SetProperty("Cells(1, 1)\Interior\Color = 18915966")
ExcelObject\SetProperty("Cells(1, 2)\Interior\Color = 18915966")
ExcelObject\SetProperty("Cells(2, 1)\Interior\Color = 18915966")
ExcelObject\SetProperty("Cells(2, 2)\Interior\Color = 18915966")
ExcelObject\SetProperty("Cells(1, 1)\Font\Color = 255255255")
ExcelObject\SetProperty("Cells(1, 2)\Font\Color = 255255255")
ExcelObject\SetProperty("Cells(2, 1)\Font\Color = 255255255")
ExcelObject\SetProperty("Cells(2, 2)\Font\Color = 255255255")
ExcelObject\GetObjectProperty("Sheets('3')\Delete")
ExcelObject\GetObjectProperty("Sheets('2')\Delete")
ExcelObject\SetProperty("Cells(1, 1)\HorizontalAlignment = -4152") ;-4152 = xlRight
ExcelObject\SetProperty("Cells(1, 2)\HorizontalAlignment = -4152") ;-4152 = xlRight
ExcelObject\SetProperty("Cells(2, 1)\HorizontalAlignment = -4152") ;-4152 = xlRight
ExcelObject\SetProperty("Cells(2, 2)\HorizontalAlignment = -4152") ;-4152 = xlRight
ExcelObject\SetProperty("Cells(1, 1)\Borders(7)\LineStyle = 1") ;7 = xlEdgeLeft ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(1, 1)\Borders(8)\LineStyle = 1") ;8 = xlEdgeTop ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(1, 1)\Borders(9)\LineStyle = 1") ;9 = xlEdgeBottom ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(1, 1)\Borders(10)\LineStyle = 1") ;10 = xlEdgeRight ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(1, 2)\Borders(7)\LineStyle = 1") ;7 = xlEdgeLeft ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(1, 2)\Borders(8)\LineStyle = 1") ;8 = xlEdgeTop ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(1, 2)\Borders(9)\LineStyle = 1") ;9 = xlEdgeBottom ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(1, 2)\Borders(10)\LineStyle = 1") ;10 = xlEdgeRight ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(2, 1)\Borders(7)\LineStyle = 1") ;7 = xlEdgeLeft ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(2, 1)\Borders(8)\LineStyle = 1") ;8 = xlEdgeTop ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(2, 1)\Borders(9)\LineStyle = 1") ;9 = xlEdgeBottom ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(2, 1)\Borders(10)\LineStyle = 1") ;10 = xlEdgeRight ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(2, 2)\Borders(7)\LineStyle = 1") ;7 = xlEdgeLeft ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(2, 2)\Borders(8)\LineStyle = 1") ;8 = xlEdgeTop ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(2, 2)\Borders(9)\LineStyle = 1") ;9 = xlEdgeBottom ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(2, 2)\Borders(10)\LineStyle = 1") ;10 = xlEdgeRight ; 1 = xlContinuous
ExcelObject\SetProperty("Cells(1, 1)\Borders(7)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(1, 1)\Borders(8)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(1, 1)\Borders(9)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(1, 1)\Borders(10)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(1, 2)\Borders(7)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(1, 2)\Borders(8)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(1, 2)\Borders(9)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(1, 2)\Borders(10)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(2, 1)\Borders(7)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(2, 1)\Borders(8)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(2, 1)\Borders(9)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(2, 1)\Borders(10)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(2, 2)\Borders(7)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(2, 2)\Borders(8)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(2, 2)\Borders(9)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("Cells(2, 2)\Borders(10)\Weight = 2") ;2 = xlThin
ExcelObject\SetProperty("DisplayToolbar = #False")
ExcelObject\SetProperty("ScreenUpdating = #True")
ExcelObject\SetProperty("ViewOnlyMode = #True") ;Schreibschutz
ExcelObject\SetProperty("DisplayOfficeLogo = #False")
ExcelObject\SetProperty("DisplayTitleBar = #False")
ExcelObject\SetProperty("ActiveWindow\ViewableRange = 'A1:B2'")
Else
Debug "!mySpreadsheet"
EndIf
ButtonGadget(0, 10, 10, 200, 20, "Copy")
HideWindow(0,0)
If ExcelObject
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_Gadget
If EventGadget()=0
ExcelObject\Invoke("Sheets(1)\Cells\Copy")
obSheet=ExcelObject\Invoke("Sheets\add")
strActiveName.s=ExcelObject\GetStringProperty("ActiveSheet\Name")
ExcelObject\Invoke("Sheets('"+strActiveName.s+"')\Cells\Paste")
ExcelObject\SetProperty("ViewableRange='A1:B2'")
ExcelObject\SetProperty("DisplayToolbar=#False")
ExcelObject\SetProperty("DisplayOfficeLogo=#False")
ExcelObject\SetProperty("DisplayTitleBar=#False")
ExcelObject\SetProperty("DisplayHorizontalScrollBar=#False")
ExcelObject\SetProperty("DisplayAlert=#False")
ExcelObject\SetProperty("AllowPropertyToolbox=#False")
EndIf
EndIf
Until EventID=#PB_Event_CloseWindow
ExcelObject\Release()
EndIf
CloseWindow(0)
EndIf
Code: Select all
objSpreadsheet\Invoke("Sheets(1)\copy")