ComatePlus excel

Just starting out? Need help? Post your questions and find answers here.
User avatar
captain_skank
Enthusiast
Enthusiast
Posts: 636
Joined: Fri Oct 06, 2006 3:57 pm
Location: England

ComatePlus excel

Post by captain_skank »

Hi All,

One for all you comateplus & excel experts

How do I get the value from another worksheet ( '0 - Summary' ) into my current worksheet ?

Neither of these work and i'm not sure where I would look for an error.

Code: Select all

ExcelObject\SetProperty("Cells(4,3) = '=SUM('0 - Summary'!E621:E795)'")
ExcelObject\SetProperty("Cells(4,4) = '='0 - Summary'!E" + LVAR_assembly_total + ")'")
Any and all help appreciated.

Cheers
Marc56us
Addict
Addict
Posts: 1479
Joined: Sat Feb 08, 2014 3:26 pm

Re: ComatePlus excel

Post by Marc56us »

Remove the apostrophes around the name of the sheet.
SUM( ' 0 - Summary ' !E621:E795)

Code: Select all

ExcelObject\SetProperty("Cells(4,3) = '=SUM(0 - Summary!E621:E795)'")
Works
:wink:
User avatar
captain_skank
Enthusiast
Enthusiast
Posts: 636
Joined: Fri Oct 06, 2006 3:57 pm
Location: England

Re: ComatePlus excel

Post by captain_skank »

Thanks for the reply.

Very strange, this puts the correct formula in the cell, but then opens a 'Save Sheet' window, and the formula doesn't calculate.

I have no other excel code after this statement either.

Oh well, I found another way to acheive the same result ( by storing the value of the cell in a variable ).

Cheers
Marc56us
Addict
Addict
Posts: 1479
Joined: Sat Feb 08, 2014 3:26 pm

Re: ComatePlus excel

Post by Marc56us »

You're right, there's something strange about the character management.
If you make a macro with the recorder, it adds characters around the sheet name, but if you put them back into ComatePlus it does not work.

(For the recording request message, you can delete it with \SetProperty("Application\DisplayAlerts = #False") )

Full example

Code: Select all

XIncludeFile "COMatePLUS.pbi"

Define.COMateObject ExcelObject, WorkBook
ExcelObject = COMate_CreateObject("Excel.Application")

If ExcelObject
    If ExcelObject\SetProperty("Visible = #True") = #S_OK
        WorkBook = ExcelObject\GetObjectProperty("Workbooks\Add")
        
        If WorkBook
            With ExcelObject
                \SetProperty("Application\DisplayAlerts = #False")     
                \invoke("Worksheets\Add")
                \SetProperty("ActiveSheet\Name('0 - Summary')")
                \SetProperty("Cells(1,1) = '1'")
                \SetProperty("Cells(2,1) = '2'")
                
                \invoke("Worksheets\Add")
                \SetProperty("ActiveSheet\Name('Total')")    
                \SetProperty("Cells(3,1) = '=SUM(0 - Summary!A1:A2)'")
                
                ;Delay(2000)
                ;\Invoke("Quit()") 
            EndWith
        EndIf
    EndIf
    ExcelObject\Release()
Else
    MessageRequester("COMate -Excel demo", "Couldn't create the application object!")
EndIf 
Here we have #Value in A3
If we edit A3 and add the ' ' in sheet name then it works.
But if you put them in Comate then it doesn't work.
I don't get it anymore.

:?
User avatar
captain_skank
Enthusiast
Enthusiast
Posts: 636
Joined: Fri Oct 06, 2006 3:57 pm
Location: England

Re: ComatePlus excel

Post by captain_skank »

Thanks for having a look - and confirming i'm not going nuts :mrgreen:

I guess it's the way Comate is parsing content within the existing ' '.

Anyhoo, as I said i have a solution so no big problem.
Marc56us
Addict
Addict
Posts: 1479
Joined: Sat Feb 08, 2014 3:26 pm

Re: ComatePlus excel

Post by Marc56us »

Perfect if it works with your solution.

As I'm also interested in the question and I noticed that it only bugs if the name of the sheet contains one or more spaces. With a name without spaces, it works. :)

I found this by doing a test with Excel's macro recorder. It puts ' ' only if the name contains one or more spaces.

So while waiting for someone to modify the .PBI and if you are free to name the sheets, you have the alternative of putting sheet names without spaces and so use your first method.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: ComatePlus excel

Post by srod »

If you wish to use the single apostrophe character within a COMate quoted string parameter then you must use a COMate escape code, in this case $0027.

Code: Select all

ExcelObject\SetProperty("Cells(4,3) = '=SUM($00270 - Summary$0027!E621:E795)'")
I may look like a mule, but I'm not a complete ass.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5353
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: ComatePlus excel

Post by Kwai chang caine »

Works here 8)

Hello great MASTER SROD Image
Always happy to see, that even if you are not with us often now and that miss me :( , you throw always a little eye sometime for protect your "PB childs" :wink: 8)
ImageThe happiness is a road...
Not a destination
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: ComatePlus excel

Post by srod »

Hi Kwai,

always good to see you about these forums. :)

As it turns out I am here quite a bit at the moment as hospital treatment has forced me to pause my day job whilst I repair and recover. Truth is, that it is probably 50:50 whether I will be able to return to work anyhow given the invasive treatment that lies before me and so, well, more time for coding. Not the way I would have liked to have made more time for programming, but, needs must sometimes. :)

Can't complain. Programming was always what I was 'best' at (a matter of opinion really I guess! :D ) and so I will not be overly distressed if I have to spend all of my time coding! :wink:
I may look like a mule, but I'm not a complete ass.
User avatar
captain_skank
Enthusiast
Enthusiast
Posts: 636
Joined: Fri Oct 06, 2006 3:57 pm
Location: England

Re: ComatePlus excel

Post by captain_skank »

Hey SROD,

Sorry to hear about your health and hope things soon pick up for you.

Thanks for the escape info, that had completely gone out of my head - been a while since i'd used ComatePlus.

As your going to be laid up for a while, are you going to get back into PB coding ? I'd really love to pay for an update to your excellent Arctic Reports ( Export to PDF, and Excel in particular ).

As always it's great to see you on the forums.

Cheers
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: ComatePlus excel

Post by srod »

Yep, nothing else to do really and so I am hoping for plenty of coding. Only the ongoing treatments and side effects will get in the way, but am hoping that won't hold me up too much. The work involved in my little self-employed business was quite physical which is why I think that it will probably have to bite the dust. Shame as it was paying the bills and keeping me fit.

As for Arctic Reports; I fully hope to upgrade/replace that with something more robust and flexible. Free upgrade of course. Have to finish the cross-platform grid control first mind which was looking great and nearing completion until I decided that we ideally needed to be able to embed child grids within a given grid control which necessitated a restart! Should be back on track soon with that as I can carry across much of the existing code base albeit in a slightly different form.
I may look like a mule, but I'm not a complete ass.
User avatar
skywalk
Addict
Addict
Posts: 3997
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: ComatePlus excel

Post by skywalk »

Very sorry to hear your health status. :cry:
Here's hoping the power of positivity and programming are fruitful.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5353
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: ComatePlus excel

Post by Kwai chang caine »

Thanks a lot great master for disclose a little part of your life 8)
It's fundamental for a fan, to have this style of informations about his heroes, against never have news and waiting weeks after weeks, month after month, with questions in the head (and you good know, that already with nothing, you fill the head of kcc :mrgreen: ), and that also show, how much the forum is important for you too :wink:
I know it will not help :oops: , but know that this announcement saddens me and i am wholeheartedly with you, as well as many family members surely :wink:
That's why, reading such news, sadly reminds us of life :|
Then.... again thanks a lot, and courage 8)

When i thinking about what you say, use your muscles when you have an also powerfull brain....it's not a bit of a waste ? :shock: :mrgreen:

You are a one of the main member of this forum, and mainly one of the most old i know (for old ...i talk about the forum :wink: ). I always remember your "crash car" avatar :mrgreen:
One of the great masters, who put me in the eyes an already very long time ago, these stars that have never left since :shock:
And that...Kcc never remember how programming....but he always remember what you have do for him and obviously all the others members 8)

It's funny... because not long ago, the great master NETMAESTRO also came back to say a little hello too :shock: 8)
Again SPARKIE, TsSoft and some members, and it's a big part of the brain power and my heroes who come back, like in the old time :D
Image
ImageThe happiness is a road...
Not a destination
Post Reply