Avatar billede soeren_soelv Novice
13. april 2008 - 13:27 Der er 3 kommentarer og
1 løsning

Afvikling af VB code ved åbning og lukning af excel-fil

Jeg vil gerne have at der bliver afviklet en VB kode når jeg åbner en excel-fil og når jeg lukker den igen.

Denne kode vil jeg gerne have afviklet ved start:

Sub MyFullScreenOn()

    Application.ScreenUpdating = False
    For Each cB In CommandBars
        If cB.Type = msoBarTypeNormal Then
          cB.Visible = False
        End If
    Next cB
    ActiveWindow.DisplayWorkbookTabs = False
    Application.DisplayFullScreen = True
    Application.CommandBars("Full Screen").Visible = False
  Application.ScreenUpdating = True
 
End Sub

Og denne kode vil jeg gerne have afviklet ved lukning af excel-filen.

Sub MyFullScreenOff()

  Application.ScreenUpdating = False
  Application.DisplayFullScreen = False
  ActiveWindow.DisplayWorkbookTabs = True
  Application.CommandBars("Standard").Visible = True
  Application.CommandBars("Formatting").Visible = True
  Application.ScreenUpdating = True
 
End Sub
Avatar billede kabbak Professor
13. april 2008 - 14:04 #1
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.ScreenUpdating = False
    For Each cB In CommandBars
        If cB.Type = msoBarTypeNormal Then
          cB.Visible = False
        End If
    Next cB
    ActiveWindow.DisplayWorkbookTabs = False
    Application.DisplayFullScreen = True
    Application.CommandBars("Full Screen").Visible = False
  Application.ScreenUpdating = True
End Sub

Private Sub Workbook_Open()
Application.ScreenUpdating = False
  Application.DisplayFullScreen = False
  ActiveWindow.DisplayWorkbookTabs = True
  Application.CommandBars("Standard").Visible = True
  Application.CommandBars("Formatting").Visible = True
  Application.ScreenUpdating = True
End Sub


De skal i ThisWorkbook modulet
Avatar billede kabbak Professor
13. april 2008 - 14:05 #2
Hov, jeg fik byttet om på koderne.


Private Sub Workbook_Open()
Application.ScreenUpdating = False
    For Each cB In CommandBars
        If cB.Type = msoBarTypeNormal Then
          cB.Visible = False
        End If
    Next cB
    ActiveWindow.DisplayWorkbookTabs = False
    Application.DisplayFullScreen = True
    Application.CommandBars("Full Screen").Visible = False
  Application.ScreenUpdating = True
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.ScreenUpdating = False
  Application.DisplayFullScreen = False
  ActiveWindow.DisplayWorkbookTabs = True
  Application.CommandBars("Standard").Visible = True
  Application.CommandBars("Formatting").Visible = True
  Application.ScreenUpdating = True
End Sub
Avatar billede soeren_soelv Novice
16. april 2008 - 15:46 #3
fino, send et svar.
Avatar billede kabbak Professor
16. april 2008 - 18:31 #4
et svar ;-))
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Excel kurser for alle niveauer og behov – find det kursus, der passer til dig

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester