Skip i'r prif gynnwys

Sut i ehangu pob ffolder yn awtomatig wrth gychwyn Outlook?

Yn nodweddiadol, pan fyddwch chi'n ehangu neu'n cwympo ffolder yn Cwarel Navigation Outlook ac wedyn yn cau'r rhaglen, mae'r ffolder yn cadw ei gyflwr ehangedig neu chwympo wrth ailagor Outlook. Fodd bynnag, beth os ydych chi am i bob ffolder gael ei ehangu'n awtomatig bob tro y byddwch chi'n dechrau Outlook? Mae'r erthygl hon yn darparu ateb VBA i gyflawni hynny.

Ehangwch bob ffolder yn awtomatig wrth gychwyn Outlook gan ddefnyddio VBA

Tab Office - Galluogi Golygu a Phori Tabiau yn Microsoft Office, Gwneud Gwaith yn Awel
Kutools ar gyfer Outlook - Hwb Outlook gyda 100 + Nodweddion Uwch ar gyfer Effeithlonrwydd Superior
Rhowch hwb i'ch Outlook 2021 - 2010 neu Outlook 365 gyda'r nodweddion uwch hyn. Mwynhewch dreial cynhwysfawr am ddim 60 diwrnod a dyrchafwch eich profiad e-bost!

swigen dde glas saeth Ehangwch bob ffolder yn awtomatig wrth gychwyn Outlook gan ddefnyddio VBA

Bydd y canllaw hwn yn dangos sut i ddefnyddio sgript VBA i ehangu'r holl ffolderi yn y Cwarel Navigation yn awtomatig bob tro y byddwch yn lansio Outlook. Dilynwch y camau hyn i weithredu'r sgript VBA:

  1. Pwyswch Alt + F11 allweddi ar yr un pryd i agor y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.
  2. Ehangu Prosiect 1 ac Gwrthrychau Microsoft Outlook yn y Prosiect cwarel, cliciwch ddwywaith i agor y SesiwnOutlook ffenestr, ac yna gludwch y cod VBA isod i mewn iddo.

    VBA: Ehangu pob ffolder yn Outlook yn awtomatig

    Public WithEvents GEx As Explorer
    Public GFlag As Boolean
    Private Sub Application_Startup()
      'Update by ExtendOffice 2023/12/08
      Set GEx = Application.ActiveExplorer
      GFlag = False
    End Sub
    
    Private Sub GEx_SelectionChange()
      If GFlag = False Then
        ExpandAllFolders
      End If
      GFlag = True
    End Sub
    
    Public Sub ExpandAllFolders()
      Dim xNameSpace As Outlook.NameSpace
      Dim xFlds As Outlook.Folders
      Dim xCurrFld As Outlook.MAPIFolder
      Dim xFld As Outlook.MAPIFolder
      Dim xExpandDefaultStoreOnly As Boolean
      Dim xModule As NavigationModule
      On Error Resume Next
      xExpandDefaultStoreOnly = False
      Set xNameSpace = Application.Session
      Set xModule = Application.ActiveExplorer.NavigationPane.CurrentModule
      Set xCurrFld = Application.ActiveExplorer.CurrentFolder
      If xExpandDefaultStoreOnly = True Then
        Set xFld = xNameSpace.GetDefaultFolder(olFolderInbox)
        Set xFld = xFld.Parent
        Set xFlds = xFld.Folders
        LoopFolders xFlds, True
      Else
        LoopFolders xNameSpace.Folders, True
        LoopFolders xNameSpace.Folders, False
      End If
      DoEvents
      Set Application.ActiveExplorer.NavigationPane.CurrentModule = xModule
      Set Application.ActiveExplorer.CurrentFolder = xCurrFld
      Set xNameSpace = Nothing
      Set xModule = Nothing
      Set xCurrFld = Nothing
    End Sub
    
    Private Sub LoopFolders(Flds As Outlook.Folders, ByVal All As Boolean)
      Dim xFld As Outlook.MAPIFolder
      On Error Resume Next
      For Each xFld In Flds
        Select Case All
          Case True
            If xFld.DefaultItemType = olMailItem Then
              Set Application.ActiveExplorer.CurrentFolder = xFld
              DoEvents
              If xFld.Folders.Count > 0 Then
                LoopFolders xFld.Folders, All
              End If
            End If
          Case False
            Set Application.ActiveExplorer.CurrentFolder = xFld
            DoEvents
            If xFld.Folders.Count > 0 Then
              LoopFolders xFld.Folders, All
            End If
        End Select
      Next
    End Sub
  3. Arbedwch y cod a chau'r Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.

O hyn ymlaen, wrth ailgychwyn Outlook, bydd yr holl ffolderau'n cael eu hehangu'n awtomatig yn Outlook.

Nodiadau:

  • Ni all y VBA hwn agor y ffolderi chwilio cwympo wrth ailgychwyn Outlook.
  • Er mwyn sicrhau bod y sgript VBA yn gweithredu'n gywir, mae'n hanfodol addasu'ch gosodiadau macro yn Outlook. Os gwelwch yn dda ewch i Ffeil > Dewisiadau > Canolfan yr Ymddiriedolaeth > Gosodiadau Canolfan Ymddiriedolaeth > Gosodiadau Macro, a dewiswch y Galluogi pob macros opsiwn. Mae'r gosodiad hwn yn caniatáu i'r sgript VBA redeg heb unrhyw gyfyngiadau.

swigen dde glas saeth Erthyglau Perthnasol


Offer Cynhyrchiant Swyddfa Gorau

Kutools ar gyfer Rhagolwg - Dros 100 o Nodweddion Pwerus i Werthu Eich Outlook

🤖 Cynorthwy-ydd Post AI: E-byst pro ar unwaith gyda hud AI - un clic i atebion athrylith, tôn berffaith, meistrolaeth amlieithog. Trawsnewid e-bostio yn ddiymdrech! ...

📧 E-bostio Automation: Allan o'r Swyddfa (Ar gael ar gyfer POP ac IMAP)  /  Amserlen Anfon E-byst  /  Auto CC/BCC gan Reolau Wrth Anfon E-bost  /  Awto Ymlaen (Rheolau Uwch)   /  Auto Ychwanegu Cyfarchiad   /  Rhannwch E-byst Aml-Dderbynnydd yn Negeseuon Unigol yn Awtomatig ...

📨 Rheoli E-bost: Dwyn i gof E-byst yn Hawdd  /  Rhwystro E-byst Sgam gan Bynciau ac Eraill  /  Dileu E-byst Dyblyg  /  Chwilio Manwl  /  Cydgrynhoi Ffolderi ...

📁 Ymlyniadau ProArbed Swp  /  Swp Datgysylltu  /  Cywasgu Swp  /  Auto Achub   /  Datgysylltiad Auto  /  Cywasgiad Auto ...

🌟 Rhyngwyneb Hud: 😊Mwy o Emojis Pretty a Cŵl   /  Rhowch hwb i'ch Cynhyrchiant Outlook gyda Golygfeydd Tabbed  /  Lleihau Outlook Yn lle Cau ...

???? Rhyfeddodau un clic: Ateb Pawb ag Ymlyniadau Dod i Mewn  /   E-byst Gwrth-Gwe-rwydo  /  🕘Dangos Parth Amser yr Anfonwr ...

👩🏼‍🤝‍👩🏻 Cysylltiadau a Chalendr: Swp Ychwanegu Cysylltiadau O E-byst Dethol  /  Rhannwch Grŵp Cyswllt i Grwpiau Unigol  /  Dileu Atgoffa Pen-blwydd ...

Dros Nodweddion 100 Aros Eich Archwiliad! Cliciwch Yma i Ddarganfod Mwy.

 

 

Comments (8)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Just tried this on Microsoft® Outlook® for Microsoft 365 MSO (Version 2310 Build 16.0.16924.20054) 64-bit and it was unsuccessful
This comment was minimized by the moderator on the site
Hi there,

Please go to File > Options > Trust Center > Trust Center Settings > Macro Settings. And select the Enable all macros option. After making this change, restart Outlook, the macro should then be operational.
This comment was minimized by the moderator on the site
Hi guys,

does this code also work for Microsoft outlook 365?
I have tried and tried again, but I get no results.
Thanks.
This comment was minimized by the moderator on the site
I couldn't get this macro to work either.
This comment was minimized by the moderator on the site
Hi there,
We've updated the code, please try it again. 🙂
Amanda
This comment was minimized by the moderator on the site
I cannot get this macro to work at all.  All folders in the Folder pane are not expanded at all.  I am using Outlook 2021.  Is there some instruction I missed?
This comment was minimized by the moderator on the site
Hi there,
We've updated the code, please try it again. 🙂
Amanda
This comment was minimized by the moderator on the site
Thank you so much.. It solved my problem. :)
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations