COMatePLUS version 1.2

Developed or developing a new product in PureBasic? Tell the world about it.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: COMatePLUS version 1.2

Post by srod »

Yes should be possible.

You can use COMatePLUS to create an instance of the relevant ActiveX control and for that you will need to know either the ProgID of the control or it's CLSID. Once you have this then it should be relatively easy.

Afraid I cannot really help because I do not own a copy of Crystal Reports.
I may look like a mule, but I'm not a complete ass.
User avatar
captain_skank
Enthusiast
Enthusiast
Posts: 639
Joined: Fri Oct 06, 2006 3:57 pm
Location: England

Re: COMatePLUS version 1.2

Post by captain_skank »

Thanks for the reply srod.

is there an easy way to find the progid or clsid ?? I tried using regedit searching for crystalactivexreportviewer and got nothing although i can find an entry for CRAXDRT which is the designer runtime library. (crystalruntime.application.11)

What i don't really understand is that to make this simple example work in vb I had to include the reference to the designer runtime library as well as the viewer control and I don't see how that translates with comateplus.

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

Re: COMatePLUS version 1.2

Post by srod »

I wouldn't worry about adding references; that is for VB's benefit in that it requires such references to type libraries so that it can look up all of the relevant interfaces and property/method listings and CLSIDs etc. ALL COMatePLUS requires are the progID's.

Use a type-library viewer tool to look within the relevant type-library for the ProgIDs. Though I would have thought you could use the tools which come with VB to do this.
I may look like a mule, but I'm not a complete ass.
akee
Enthusiast
Enthusiast
Posts: 496
Joined: Wed Aug 18, 2004 9:52 am
Location: Penang, Malaysia

Re: COMatePLUS version 1.2

Post by akee »

Hi! I tried accessing the serial number using GetIntegerProperty() but got additional information... :)

Code: Select all

XIncludeFile "COMatePLUS.pbi"

Define.COMateObject objFSO, objDrive
Define.COMateEnumObject colDrives

#DRIVE_TYPE_UNKNOWN   = 0
#DRIVE_TYPE_REMOVABLE = 1
#DRIVE_TYPE_FIXED     = 2
#DRIVE_TYPE_NETWORK   = 3
#DRIVE_TYPE_CDROM     = 4
#DRIVE_TYPE_RAMDISK   = 5


objFSO = COMate_CreateObject("Scripting.FileSystemObject") 

If objFSO
  colDrives = objFSO\CreateEnumeration("Drives") 
  If colDrives
    objDrive = colDrives\GetNextObject() 
    While objDrive
      Debug "Drive letter: " + objDrive\GetStringProperty("DriveLetter")
      Debug "Drive type  : " + Str(objDrive\GetIntegerProperty("DriveType"))
      If objDrive\GetIntegerProperty("DriveType") = #DRIVE_TYPE_REMOVABLE
        Debug "Volume Label  : " + objDrive\GetStringProperty("VolumeName")
        Debug "Serial No     : " + Hex(objDrive\GetIntegerProperty("SerialNumber"))
                          ; My Serial # is D28D-F008
                          ; but appears as FFFFFFFFD28DF008
      EndIf
      Debug ""
      objDrive\Release() 
      objDrive = colDrives\GetNextObject() 
    Wend 
    colDrives\Release() 
  EndIf
  objFSO\Release()
EndIf
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: COMatePLUS version 1.2

Post by srod »

The GetIntegerProperty() will return a quad and Hex() works with quads.

Use the following :

Code: Select all

Debug "Serial No     : " + Hex(objDrive\GetIntegerProperty("SerialNumber"), #PB_Long)
I may look like a mule, but I'm not a complete ass.
akee
Enthusiast
Enthusiast
Posts: 496
Joined: Wed Aug 18, 2004 9:52 am
Location: Penang, Malaysia

Re: COMatePLUS version 1.2

Post by akee »

Thanks srod... :)
Yogi Yang
Enthusiast
Enthusiast
Posts: 107
Joined: Sun Dec 11, 2005 2:19 pm

Re: COMatePLUS version 1.2

Post by Yogi Yang »

Thanks Srod... I really like this!
:)
--
Yogi Yang
User avatar
flaith
Enthusiast
Enthusiast
Posts: 704
Joined: Mon Apr 25, 2005 9:28 pm
Location: $300:20 58 FC 60 - Rennes
Contact:

Re: COMatePLUS version 1.2

Post by flaith »

Hi all :)

i have a Excel Workbook with 2 sheets, each have a password to protect cells, the second sheet is invisible :
Private Sub Worksheet_Activate()
Sheets(2).Visible = xlVeryHidden
'Sheets(2).Visible = True
End Sub
i also tried with visible sheet

i need to unprotect my second sheet (with COMatePlus) and tried without success, here is a part of the code :

Code: Select all

;Check if the sheet is protected
;False = 0
;True = -1
debug ExcelObject\GetIntegerProperty("Sheets(2)\ProtectContents")
ExcelObject\SetProperty("Worksheets(2)\Unprotect Password = 'MyPassword'")
;or tried with
;ExcelObject\SetProperty("Sheets(2)\Unprotect Password = 'MyPassword'")
;or with
;ExcelObject\SetProperty("Sheets('Data')\Unprotect Password = 'MyPassword', UserInterfaceOnly = Vrai") ; tried with True : same

ExcelObject\SetProperty("Sheets(2)\Cells(1,7) = 'New Client'")
ExcelObject\Invoke("ActiveWorkBook\Save()")
Thanks for you help :D
“Fear is a reaction. Courage is a decision.” - WC
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: COMatePLUS version 1.2

Post by srod »

The following worked fine here :

Code: Select all

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

If ExcelObject
  If ExcelObject\SetProperty("Visible = #True") = #S_OK
    WorkBook = ExcelObject\GetObjectProperty("Workbooks\Open('c:\Pure basic - 4.3\COMatePLUS-PB4.50\Basic demos\test.xls')") 
    If WorkBook
      WorkBook\Invoke("Sheets(1)\Unprotect('" + password$ + "')")
      WorkBook\Release()
    EndIf
  EndIf
  ExcelObject\Invoke("Quit()") 
  ExcelObject\Release()
Else
  MessageRequester("COMate -Excel demo", "Couldn't create the application object!")
EndIf
I may look like a mule, but I'm not a complete ass.
User avatar
flaith
Enthusiast
Enthusiast
Posts: 704
Joined: Mon Apr 25, 2005 9:28 pm
Location: $300:20 58 FC 60 - Rennes
Contact:

Re: COMatePLUS version 1.2

Post by flaith »

Thanks a lot srod Image
“Fear is a reaction. Courage is a decision.” - WC
User avatar
flaith
Enthusiast
Enthusiast
Posts: 704
Joined: Mon Apr 25, 2005 9:28 pm
Location: $300:20 58 FC 60 - Rennes
Contact:

Re: COMatePLUS version 1.2

Post by flaith »

Just a little behavior with the Demo Excel :

add this line and run :

Code: Select all

ExcelObject\SetProperty("Cells(1,7) = '$A$2:$A$4'")
The Cell(1,7) will display $A$2:$A (loosing $4) :mrgreen:
“Fear is a reaction. Courage is a decision.” - WC
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: COMatePLUS version 1.2

Post by srod »

The $ is an escape code for COMate and COMatePLUS.

Whenever COMate encounters a $ within a string argument it then regards the next 4 characters as a Hex character code (Ascii or Unicode). For example, $0024 would equate to character code 36 which is a '$' character.

Replace your statement above by :

Code: Select all

ExcelObject\SetProperty("Cells(1,7) = '$0024A$00242:$0024A$00244'")
I may look like a mule, but I'm not a complete ass.
User avatar
flaith
Enthusiast
Enthusiast
Posts: 704
Joined: Mon Apr 25, 2005 9:28 pm
Location: $300:20 58 FC 60 - Rennes
Contact:

Re: COMatePLUS version 1.2

Post by flaith »

:D ImageThank you so much
“Fear is a reaction. Courage is a decision.” - WC
Nico
Enthusiast
Enthusiast
Posts: 274
Joined: Sun Jan 11, 2004 11:34 am
Location: France

Re: COMatePLUS version 1.2

Post by Nico »

I try to record a voice to a file, the file is created but empty
Can you help me?

Code: Select all

XIncludeFile "COMatePLUS.pbi"

#SSFMCreateForWrite=3

spVoice.COMateObject = COMate_CreateObject("SAPI.SpVoice")
SpFileStream.COMateObject = COMate_CreateObject("SAPI.SpFileStream")

If SpFileStream<>0 And spVoice<>0
  
  SpFileStream\invoke("open('c:\essai.wav' ,3, #False)")

  spVoice\SetPropertyref("AudioOutputStream=SpFileStream as COMateObject")

  spVoice\Invoke("speak('Purebasic is very nice')")
  
  SpFileStream\invoke("close()")
  SpFileStream\Release()
  spVoice\Release()
EndIf 
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: COMatePLUS version 1.2

Post by srod »

Code: Select all

spVoice\SetPropertyRef("AudioOutputStream=" + Str(SpFileStream) + " As COMateObject")
I may look like a mule, but I'm not a complete ass.
Post Reply