Page 13 of 23

Re: COMatePLUS version 1.2

Posted: Tue Aug 17, 2010 9:24 am
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.

Re: COMatePLUS version 1.2

Posted: Tue Aug 17, 2010 10:51 am
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

Re: COMatePLUS version 1.2

Posted: Tue Aug 17, 2010 11:00 am
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.

Re: COMatePLUS version 1.2

Posted: Sun Aug 22, 2010 4:53 pm
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

Re: COMatePLUS version 1.2

Posted: Sun Aug 22, 2010 9:06 pm
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)

Re: COMatePLUS version 1.2

Posted: Mon Aug 23, 2010 7:12 am
by akee
Thanks srod... :)

Re: COMatePLUS version 1.2

Posted: Thu Oct 07, 2010 6:11 am
by Yogi Yang
Thanks Srod... I really like this!
:)

Re: COMatePLUS version 1.2

Posted: Thu Oct 07, 2010 3:13 pm
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

Re: COMatePLUS version 1.2

Posted: Thu Oct 07, 2010 5:46 pm
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

Re: COMatePLUS version 1.2

Posted: Thu Oct 07, 2010 8:50 pm
by flaith
Thanks a lot srod Image

Re: COMatePLUS version 1.2

Posted: Fri Oct 08, 2010 3:29 pm
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:

Re: COMatePLUS version 1.2

Posted: Fri Oct 08, 2010 4:29 pm
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'")

Re: COMatePLUS version 1.2

Posted: Fri Oct 08, 2010 4:37 pm
by flaith
:D ImageThank you so much

Re: COMatePLUS version 1.2

Posted: Fri Oct 22, 2010 6:18 pm
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 

Re: COMatePLUS version 1.2

Posted: Sat Oct 23, 2010 10:12 am
by srod

Code: Select all

spVoice\SetPropertyRef("AudioOutputStream=" + Str(SpFileStream) + " As COMateObject")