PureBasic Forum
https://www.purebasic.fr/english/

ComatePlus + Excel set active sheet
https://www.purebasic.fr/english/viewtopic.php?f=27&t=69282
Page 1 of 1

Author:  Deraman [ Thu Sep 28, 2017 8:35 am ]
Post subject:  ComatePlus + Excel set active sheet

Dear, I badly need to add sheets and make one of them active using ( ComatePlus + Excel )for transferring data. Please suggest.
Thanks
Dearman

Author:  Shardik [ Fri Oct 20, 2017 9:27 pm ]
Post subject:  Re: ComatePlus + Excel set active sheet

Falko in the German forum has programmed 96 different PureBasic procedures which call Excel functions using srod's COMatePLUS.PBI. You can download COMatePLUS and ExcelFunktion.pbi from this thread.

For your conveniance I have taken the code of the required procedures to
- Create a new Excel object
- Create a new workbook and save it
- Make Excel visible
- Add a new worksheet
- Rename that worksheet

I have tested the example code below successfully on Windows 8.1 x64 with Microsoft Office 2010 and PB 5.61 x86:
Code:
XIncludeFile "Your/Path/To/COMatePLUS.PBI"

Define ExcelFile.S = GetTemporaryDirectory() + "MyExcelTestFile.xls"
Define ExcelObject.COMateObject

; ----- Create new Excel object
ExcelObject = COMate_CreateObject("Excel.Application")

If ExcelObject
  ; ----- Create new workbook
  ExcelObject\GetObjectProperty("Workbooks\Add")
  SetCurrentDirectory(ExcelFile)

  ; ----- Make Excel visible
  ExcelObject\SetProperty("Visible = #True")

  ; ----- Add new worksheet
  ExcelObject\invoke("Worksheets\Add")

  ; ----- Rename active worksheet
  ExcelObject\SetProperty("ActiveSheet\Name('My new sheet')")
EndIf

Author:  davido [ Fri Oct 20, 2017 10:08 pm ]
Post subject:  Re: ComatePlus + Excel set active sheet

@Deraman,
Thanks for asking the question.

@Shardik
Thank you for the reply.
This will prove very helpful and instructive. :D

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/