Consulting

Results 1 to 3 of 3

Thread: Opening a new file of a different format

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Opening a new file of a different format

    Hi,
    I have 2 sub routines that remove the gridlines, headings and make excel full screen. Is there a way to allow me to open another excel spreadsheet ie file new without it looping through the code below?

    So what I am seeing is when I click file new it flicks through the worksheets of my open workbook and won't let me see the other workbook that I just tried to create. It is there but I can't get to it.

    The second sub routine undoes all the changes I made to set excel back to its previous settings.

    [VBA]Private Sub Workbook_Activate()
    Dim ws As Worksheet
    Dim wb As Workbook
    Application.ScreenUpdating = False
    Application.DisplayFullScreen = True
    Set wbBook = ThisWorkbook
    For Each wsSheet In wbBook.Worksheets
    If Not wsSheet.Name = "Blank" Then
    wsSheet.Activate
    With ActiveWindow
    .DisplayHeadings = False
    .DisplayGridlines = False
    '.DisplayWorkbookTabs = True
    '.DisplayHorizontalScrollBar = False
    End With
    End If
    Next wsSheet
    Sheets("Summary").Activate
    Application.ScreenUpdating = True
    End Sub
    Private Sub Workbook_Deactivate()
    Dim ws As Worksheet
    Dim wb As Workbook
    Application.ScreenUpdating = False
    Application.DisplayFullScreen = False
    Set wbBook = ThisWorkbook
    For Each wsSheet In wbBook.Worksheets
    If Not wsSheet.Name = "Blank" Then
    wsSheet.Activate
    With ActiveWindow
    .DisplayHeadings = True
    .DisplayGridlines = True
    '.DisplayWorkbookTabs = True
    '.DisplayHorizontalScrollBar = False
    End With
    End If
    Next wsSheet
    Sheets("Summary").Activate
    Application.ScreenUpdating = True
    End Sub[/VBA]
    Last edited by Aussiebear; 03-06-2013 at 01:32 AM. Reason: Added the correct tags to the supplied code

  2. #2
    VBAX Regular
    Joined
    Feb 2012
    Posts
    31
    Location
    To help read the code easier always wrap it like below

    [vba]
    Private Sub Workbook_Activate()
    Dim ws As Worksheet
    Dim wb As Workbook
    Application.ScreenUpdating = False
    Application.DisplayFullScreen = True
    Set wbBook = ThisWorkbook
    For Each wsSheet In wbBook.Worksheets
    If Not wsSheet.Name = "Blank" Then
    wsSheet.Activate
    With ActiveWindow
    .DisplayHeadings = False
    .DisplayGridlines = False
    '.DisplayWorkbookTabs = True
    '.DisplayHorizontalScrollBar = False
    End With
    End If
    Next wsSheet
    Sheets("Summary").Activate
    Application.ScreenUpdating = True
    End Sub
    [/vba]
    Last edited by Aussiebear; 03-06-2013 at 01:32 AM. Reason: Corrected the tags surrounding the code
    ------------------------------------------------

    Thanks For All Your Help

    Windows 7

    Excel 2010

    Any codes I provide please try on a copy of your workbook first as these cannot be undone!

    To get the most precise answer, it is best to upload/attach a sample workbook (sensitive data scrubbed/removed/changed) that contains an example of your raw data on one worksheet, and on another worksheet your desired results.

    The structure and data types of the sample workbook must exactly duplicate the real workbook. Include a clear and explicit explanation of your requirements.

  3. #3
    Apologies dazwm. I just didn't realise there was a button to highlight the code.
    Now I know how to do it.

    I thought my explanation was clear.

    I didn't upload a workbook because I didn't think it was necessary with such a small piece of code that doesn't do a great deal.

    Thanks for your advice

Posting Permissions

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