It is currently Mon Nov 20, 2017 1:16 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: ComatePlus + Excel set active sheet
PostPosted: Thu Sep 28, 2017 8:35 am 
Offline
User
User

Joined: Thu Mar 10, 2016 8:00 am
Posts: 14
Dear, I badly need to add sheets and make one of them active using ( ComatePlus + Excel )for transferring data. Please suggest.
Thanks
Dearman


Top
 Profile  
Reply with quote  
 Post subject: Re: ComatePlus + Excel set active sheet
PostPosted: Fri Oct 20, 2017 9:27 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Apr 21, 2005 2:38 pm
Posts: 1461
Location: Germany
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


Top
 Profile  
Reply with quote  
 Post subject: Re: ComatePlus + Excel set active sheet
PostPosted: Fri Oct 20, 2017 10:08 pm 
Offline
Addict
Addict

Joined: Fri Nov 09, 2012 11:04 pm
Posts: 1459
Location: Uttoxeter, UK
@Deraman,
Thanks for asking the question.

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

_________________
DE AA EB


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye