+ Reply to Thread
Results 1 to 7 of 7

Worksheet has to set to visible as it is not visible after saving and closing Excel by VB.

  1. #1
    Oscar
    Guest

    Worksheet has to set to visible as it is not visible after saving and closing Excel by VB.

    After saving and closing an Excel Worksheet by VB, the only Worksheet which
    resides in the Workbook doesn't show. In order to make it visible again, I
    have to choose make visible from the format menu and select the Worksheet.

    Is there a workaround for this problem ?



  2. #2
    Forum Contributor
    Join Date
    01-21-2005
    Location
    Colorado
    MS-Off Ver
    2000,2003,2007
    Posts
    481
    You could add a Workbook _Open event procedure that will set the visibility of that worksheet to true.

    Private Sub Workbook_Open()
    Sheets("Put Worksheet Name Here").Visible = True
    End Sub

    Or you could set the visibility of the worksheet before saving and closing.

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Sheets("Put Worksheet Name Here").Visible = True
    End Sub

    Either method should give you the results you are after.

    HTH

  3. #3
    Oscar
    Guest

    Re: Worksheet has to set to visible as it is not visible after saving and closing Excel by VB.

    Hi bhofsetz,

    Since the workbook is created by another program on the fly, I can't adress
    these methods.
    Anyway I've tested the option to set the visible property to True right
    before closing but that didn't help.



    "bhofsetz" <[email protected]> schreef
    in bericht news:[email protected]...
    >
    > You could add a Workbook _Open event procedure that will set the
    > visibility of that worksheet to true.
    >
    > Private Sub Workbook_Open()
    > Sheets("Put Worksheet Name Here").Visible = True
    > End Sub
    >
    > Or you could set the visibility of the worksheet before saving and
    > closing.
    >
    > Private Sub Workbook_BeforeClose(Cancel As Boolean)
    > Sheets("Put Worksheet Name Here").Visible = True
    > End Sub
    >
    > Either method should give you the results you are after.
    >
    > HTH
    >
    >
    > --
    > bhofsetz
    > ------------------------------------------------------------------------
    > bhofsetz's Profile:
    > http://www.excelforum.com/member.php...o&userid=18807
    > View this thread: http://www.excelforum.com/showthread...hreadid=380706
    >




  4. #4
    Norman Jones
    Guest

    Re: Worksheet has to set to visible as it is not visible after saving and closing Excel by VB.

    Hi Oscar,

    Perhaps I am missing something but how can the sole sheet be hidden, as a
    workbook must have at least one sheet visible?

    Does the workbook contain sheets other than worksheets, e.g. a chart sheet.?

    Alternatively, is it perhaps the workbook which is hidden?


    ---
    Regards,
    Norman



    "Oscar" <[email protected]> wrote in message
    news:[email protected]...
    > Hi bhofsetz,
    >
    > Since the workbook is created by another program on the fly, I can't
    > adress these methods.
    > Anyway I've tested the option to set the visible property to True right
    > before closing but that didn't help.
    >
    >
    >
    > "bhofsetz" <[email protected]> schreef
    > in bericht news:[email protected]...
    >>
    >> You could add a Workbook _Open event procedure that will set the
    >> visibility of that worksheet to true.
    >>
    >> Private Sub Workbook_Open()
    >> Sheets("Put Worksheet Name Here").Visible = True
    >> End Sub
    >>
    >> Or you could set the visibility of the worksheet before saving and
    >> closing.
    >>
    >> Private Sub Workbook_BeforeClose(Cancel As Boolean)
    >> Sheets("Put Worksheet Name Here").Visible = True
    >> End Sub
    >>
    >> Either method should give you the results you are after.
    >>
    >> HTH
    >>
    >>
    >> --
    >> bhofsetz
    >> ------------------------------------------------------------------------
    >> bhofsetz's Profile:
    >> http://www.excelforum.com/member.php...o&userid=18807
    >> View this thread:
    >> http://www.excelforum.com/showthread...hreadid=380706
    >>

    >
    >




  5. #5
    Oscar
    Guest

    Re: Worksheet has to set to visible as it is not visible after saving and closing Excel by VB.


    Hi Norman,

    In case that I open the file by hand, it shows the one and only sheet.
    In case I open the file by VB :

    dim objExcel as Excel.Workbook
    Set objExcel = GetObject(pathFile)

    and set the application.visible to true by

    objExcel.Application.Visible = True

    I can't see any sheet. However, the sheet is there since I am able to
    process it in VB and also print.
    I think that the problem origin is right when opening the file by VB, since
    it doesn't show any sheet after loading

    Oscar




    "Norman Jones" <[email protected]> schreef in bericht
    news:%[email protected]...
    > Hi Oscar,
    >
    > Perhaps I am missing something but how can the sole sheet be hidden, as a
    > workbook must have at least one sheet visible?
    >
    > Does the workbook contain sheets other than worksheets, e.g. a chart
    > sheet.?
    >
    > Alternatively, is it perhaps the workbook which is hidden?
    >
    >
    > ---
    > Regards,
    > Norman
    >
    >
    >
    > "Oscar" <[email protected]> wrote in message
    > news:[email protected]...
    >> Hi bhofsetz,
    >>
    >> Since the workbook is created by another program on the fly, I can't
    >> adress these methods.
    >> Anyway I've tested the option to set the visible property to True right
    >> before closing but that didn't help.
    >>
    >>
    >>
    >> "bhofsetz" <[email protected]>
    >> schreef in bericht
    >> news:[email protected]...
    >>>
    >>> You could add a Workbook _Open event procedure that will set the
    >>> visibility of that worksheet to true.
    >>>
    >>> Private Sub Workbook_Open()
    >>> Sheets("Put Worksheet Name Here").Visible = True
    >>> End Sub
    >>>
    >>> Or you could set the visibility of the worksheet before saving and
    >>> closing.
    >>>
    >>> Private Sub Workbook_BeforeClose(Cancel As Boolean)
    >>> Sheets("Put Worksheet Name Here").Visible = True
    >>> End Sub
    >>>
    >>> Either method should give you the results you are after.
    >>>
    >>> HTH
    >>>
    >>>
    >>> --
    >>> bhofsetz
    >>> ------------------------------------------------------------------------
    >>> bhofsetz's Profile:
    >>> http://www.excelforum.com/member.php...o&userid=18807
    >>> View this thread:
    >>> http://www.excelforum.com/showthread...hreadid=380706
    >>>

    >>
    >>

    >
    >




  6. #6
    Forum Contributor
    Join Date
    01-21-2005
    Location
    Colorado
    MS-Off Ver
    2000,2003,2007
    Posts
    481
    Oscar,

    If you are ascessing the workbook and worksheet with VBA then why not just set the visible property to true when using VBA to open the workbook.

    dim objExcel as Excel.Workbook
    Set objExcel = GetObject(pathFile)

    and set the application.visible to true by

    objExcel.Application.Visible = True
    Sheets(1).Visible = True

  7. #7
    Oscar
    Guest

    Re: Worksheet has to set to visible as it is not visible after saving and closing Excel by VB.

    I've tried similar settings but nothing worked.
    Another 'weird' issue : I can't code

    Sheets(1).Visible = True

    When I press a dot after the (1) , the VB intellisense doesn't show me any
    methods or properties. In case I force to set .Visible =True an error is
    fired in runtime

    Remember that I noted that I use VB (within MS Visual Basic), not VBA in
    Excel
    ---
    Oscar



    "bhofsetz" <[email protected]> schreef
    in bericht news:[email protected]...
    >
    > Oscar,
    >
    > If you are ascessing the workbook and worksheet with VBA then why not
    > just set the visible property to true when using VBA to open the
    > workbook.
    >
    > dim objExcel as Excel.Workbook
    > Set objExcel = GetObject(pathFile)
    >
    > and set the application.visible to true by
    >
    > objExcel.Application.Visible = True
    > Sheets(1).Visible = True
    >
    >
    > --
    > bhofsetz
    > ------------------------------------------------------------------------
    > bhofsetz's Profile:
    > http://www.excelforum.com/member.php...o&userid=18807
    > View this thread: http://www.excelforum.com/showthread...hreadid=380706
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1