Announcement

Collapse
No announcement yet.

Use of the COM Browser

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Use of the COM Browser

    Hi to all !

    I just wrote some PB program which opens an Excel Workbook.

    At the point, I need to make some worksheets of the open workbook "very hidden".

    This should be done through Sheets(sheetindex).visible=2

    When I use the PB COM Browser, I got this for "sheets" "visible":
    Member Let Visible<&H0000022E>() 'Parameter Type As Variant

    In this case, and generally, in all other cases, how can I write the PB statement to accomplish the action ?

    It should be something in the genre: LET oActiveSheet.visible=2

    But I really do not know how to write in PB from what I got in the COM Browser.

    Hereunder, the actual code:
    #COMPILE EXE
    #DIM ALL
    #INCLUDE "Excel.Application.inc"

    FUNCTION PBMAIN () AS LONG
    '===Declare Variables
    'MSGBOX Variables
    DIM invite$, titre$, mycrlf$, texte$
    'INPUTBOX$ Variables
    DIM resultat$
    'Some Variables to work with
    DIM vTemp1 AS VARIANT
    DIM vTemp2 AS VARIANT
    DIM vWorkBookName AS VARIANT
    DIM vWorkSheetsCount AS VARIANT
    DIM vActiveSheet AS VARIANT
    DIM vWorkSheetName AS VARIANT
    DIM vSheetIndex AS VARIANT
    DIM vWorkSheets AS VARIANT
    DIM ptr1%,ptr2%,ptr3%
    'Object Variables
    DIM oExcelApp AS ExcelApplication
    DIM oExcelWorkbook AS ExcelWorkbook
    GLOBAL oExcelWorkSheet AS ExcelWorkSheet
    DIM oExcelChart AS ExcelChart
    DIM oExcelWorkSheets AS ExcelWorkSheets
    'Object Parameters Variables
    DIM vBool AS VARIANT
    DIM vVnt AS VARIANT
    DIM oVnt AS VARIANT
    DIM vX AS VARIANT
    DIM vY AS VARIANT
    DIM vFile AS VARIANT
    DIM vFileFmt AS VARIANT

    '===Open an instance of Excel
    SET oExcelApp=ExcelApplication IN $PROGID_ExcelApplication8
    IF ISFALSE ISOBJECT(oExcelApp) THEN
    SET oExcelApp=NEW ExcelApplication IN $PROGID_ExcelApplication8
    END IF
    'Could Excel be opened ? => if not, terminate this app
    IF ISFALSE ISOBJECT(oExcelApp) THEN
    MSGBOX "Excel could not be opened !"
    EXIT FUNCTION
    END IF

    '===Open an existing workbook in Excel
    'Set name
    LET vWorkBookName="C:\Test01.xls"
    OBJECT CALL oExcelApp.Workbooks.Open(vWorkbookName) TO oVnt
    'Copy the interface ref into Object Variable oExcelWorkbook
    SET oExcelWorkbook = oVnt

    '===Make Excel visible to the user
    LET vBool = 1
    OBJECT LET oExcelApp.Visible = vBool

    '===Close app ???
    mycrlf$ = CHR$(13) & CHR$(10)
    titre$="Info..."
    invite$="Close Workbook and Excel ??" & mycrlf$ & "<Y>es OR <N>o ..."
    resultat$ = INPUTBOX$(invite$, titre$, "")
    'MSGBOX resultat$
    IF LEFT$(UCASE$(resultat$),1) = "Y" THEN
    'Close active window
    OBJECT CALL oExcelApp.ActiveWindow.Close
    'Close Excel
    OBJECT CALL oExcelApp.Quit
    END IF

    '==Make Sheet2 veryhidden
    '????????????????????
    '????????????????????
    '????????????????????
    '????????????????????

    '===Release the Interfaces
    'We could omit this since the app is about to close
    'but "best practice" states we should clean our house before moving out !
    SET oExcelApp = NOTHING
    SET oExcelWorkbook = NOTHING
    END FUNCTION

    Thanks by advance for your reply,
    Herve+

  • #2
    You have to use variant variables to pass it.

    Code:
        DIM vBool               AS VARIANT 
    
        LET vBool = 2
        OBJECT LET oExcelWorksheet.Visible = vBool

    Comment


    • #3
      >LET vBool = 2


      Just say 'no' to Magic Numbers!!!

      From generated INCLUDE file:
      Code:
      'Enumeration XlSheetVisibility
      %xlSheetVisible                                         = &HFFFFFFFF
      %xlSheetHidden                                          = &H00000000
      %xlSheetVeryHidden                                      = &H00000002
      ===>
      Code:
          LET vBool =  [b]%xlSheetVeryHidden[/b]
      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment

      Working...
      X