[Solved]Comate Excel with Name off Cell

Just starting out? Need help? Post your questions and find answers here.
User avatar
Falko
Enthusiast
Enthusiast
Posts: 271
Joined: Sat Oct 04, 2003 12:57 pm
Location: Germany
Contact:

[Solved]Comate Excel with Name off Cell

Post by Falko »

Hello,
what is wrong here? I'll will make a Function to create a Name of a Cell in
Excel. But my COMate-ErrorDiscription tell me an Error into
... ActiveWorkbooks\Names\Add - Methode.

Is it not the same as Workbooks\add ? I don't no.

Please can anyone help me by this code?

Code: Select all

IncludePath "..\"
XIncludeFile "COMatePLUS.pbi"
DisableExplicit


Define.COMateObject ExcelObject, WorkBook, MyNames
ExcelObject = COMate_CreateObject("Excel.Application")
If ExcelObject
  If ExcelObject\SetProperty("Visible = #True") = #S_OK
      WorkBook = ExcelObject\GetObjectProperty("Workbooks\Add"):Debug COMate_GetLastErrorDescription()
    If WorkBook
   
          MyNames=ExcelObject\GetObjectProperty("ActiveWorkbook\Names\Add"):Debug COMate_GetLastErrorDescription()
          If MyNames
            Debug"MyNames aktiv"
            ;MyNames\invoke("Add") ;if you erase \Add of the Object MyNames= ....
            MyNames\SetProperty("Name := 'MyCellName'"):Debug COMate_GetLastErrorDescription()
            MyNames\SetProperty("RefersTo :='=Tabelle1!$A$1'"):Debug COMate_GetLastErrorDescription()
            MyNames\Release():Debug COMate_GetLastErrorDescription()
            ExcelObject\Invoke("Quit()") 
            MyNames\Release()  
          EndIf
          WorkBook\Release()
          ExcelObject\Release()
        EndIf
  EndIf
Else
  MessageRequester("COMate -Excel demo", "Couldn't create the application object!")
EndIf  
    
And here ist the VBA-Script for Excel
Names.Add Name:="Tante", RefersTo:="=Tabelle1!$C$3"
Thank you and regards from germany.
(sorry at my little english)

Falko
Last edited by Falko on Sat Jun 16, 2012 2:59 pm, edited 1 time in total.
www.falko-pure.de
Win11 Pro 64-Bit, PB_6.11b1
User avatar
Falko
Enthusiast
Enthusiast
Posts: 271
Joined: Sat Oct 04, 2003 12:57 pm
Location: Germany
Contact:

Re: Comate Excel with Name off Cell

Post by Falko »

Excuse me, I have found another solution

Here my code:

Code: Select all

Procedure.s XLSFunc_CreateCellName(ExcelObject.COMateObject,Range.s,CellName.s)
    ExcelObject\SetProperty("Range('"+Range+"')\Name='"+CellName+"'")
EndProcedure
:D

regards,
Falko
www.falko-pure.de
Win11 Pro 64-Bit, PB_6.11b1
Post Reply