Skip i'r prif gynnwys

Sut i gadw ffenestr excel bob amser ar ei ben?

A ydych erioed wedi dymuno cadw'ch ffenestri Excel ar ben bob amser a pheidio â chael eich gorchuddio gan ffenestri eraill? Yn anffodus, nid yw Excel yn darparu nodwedd ar gyfer datrys y dasg hon. Ond, yma, gallaf roi cod VBA i chi ddelio â'r swydd hon.

Cadwch ffenestr Excel bob amser ar ei phen gyda chod VBA


swigen dde glas saeth Cadwch ffenestr Excel bob amser ar ei phen gyda chod VBA

Gall y cod VBA canlynol eich helpu i gadw'r ffenestr Excel bob amser ar ben, mae'r cod yn cael ei gymhwyso i swyddfa 32-bit a swyddfa 64-bit.

1. Daliwch i lawr y ALT + F11 allweddi i agor y Ffenestr Microsoft Visual Basic for Applications.

2. Cliciwch Mewnosod > Modiwlau, a gludwch y cod canlynol yn y Ffenestr Modiwl.

Cod VBA: Cadwch ffenestr Excel bob amser ar ei phen

'Update 20140909
#If Win64 Then
    Public Declare PtrSafe Function SetWindowPos _
        Lib "user32" ( _
            ByVal hwnd As LongPtr, _
            ByVal hwndInsertAfter As LongPtr, _
            ByVal x As Long, ByVal y As Long, _
            ByVal cx As Long, ByVal cy As Long, _
            ByVal wFlags As Long) _
    As Long
#Else
    Public Declare Function SetWindowPos _
        Lib "user32" ( _
            ByVal hwnd As Long, _
            ByVal hwndInsertAfter As Long, _
            ByVal x As Long, ByVal y As Long, _
            ByVal cx As Long, ByVal cy As Long, _
            ByVal wFlags As Long) _
    As Long
#End If
Public Const SWP_NOSIZE = &H1
Public Const SWP_NOMOVE = &H2
Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
Sub ShowXLOnTop(ByVal OnTop As Boolean)
    Dim xStype As Long
    #If Win64 Then
        Dim xHwnd As LongPtr
    #Else
        Dim xHwnd As Long
    #End If
    If OnTop Then
        xStype = HWND_TOPMOST
    Else
        xStype = HWND_NOTOPMOST
    End If
    Call SetWindowPos(Application.hwnd, xStype, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE)
End Sub
Sub SetXLOnTop()
    ShowXLOnTop True
End Sub
Sub SetXLNormal()
    ShowXLOnTop False
End Sub

3. Yna pwyswch F5 allwedd i redeg y cod hwn, ac a Macros bydd blwch deialog yn ymddangos, dewiswch SetXLOnTop opsiwn, a chlicio Run botwm.

doc-cadw-excel-ar-ben-1

4. Ac yna bydd eich ffenestr Excel bob amser ar ben cymwysiadau eraill.

Nodyn: Os ydych chi am ddychwelyd y ffenestr Excel yn normal, pwyswch F5 allweddol i agor y Macros deialog, dewiswch SetXNormal a chliciwch Run.

Offer Cynhyrchiant Swyddfa Gorau

🤖 Kutools AI Aide: Chwyldro dadansoddi data yn seiliedig ar: Cyflawniad Deallus   |  Cynhyrchu Cod  |  Creu Fformiwlâu Personol  |  Dadansoddi Data a Chynhyrchu Siartiau  |  Invoke Swyddogaethau Kutools...
Nodweddion Poblogaidd: Darganfod, Amlygu neu Adnabod Dyblygiadau   |  Dileu Rhesi Gwag   |  Cyfuno Colofnau neu Gelloedd heb Colli Data   |   Rownd heb Fformiwla ...
Super-edrych: VLookup Meini Prawf Lluosog    VLookup Gwerth Lluosog  |   VLookup Ar Draws Taflenni Lluosog   |   Edrych Niwlog ....
Rhestr gwympo Uwch: Creu Rhestr Gollwng yn Gyflym   |  Rhestr Gollwng Dibynnol   |  Rhestr Gollwng Aml-ddewis ....
Rheolwr Colofn: Ychwanegu Nifer Penodol o Golofnau  |  Symud Colofnau  |  Toglo Statws Gwelededd Colofnau Cudd  |  Cymharwch Ystodau a Cholofnau ...
Nodweddion dan Sylw: Ffocws ar y Grid   |  Golwg Dylunio   |   Bar Fformiwla Mawr    Rheolwr Llyfr Gwaith a Thaflen   |  Llyfrgell Adnoddau (Testun Auto)   |  Dewiswr Dyddiad   |  Cyfuno Taflenni Gwaith   |  Amgryptio/Dadgryptio Celloedd    Anfon E-byst trwy Restr   |  Hidlo Super   |   Hidlo Arbennig (hidlo mewn print trwm/italig/strikethrough...) ...
15 Set Offer Gorau12 Testun offer (Ychwanegu Testun, Dileu Cymeriadau,...)   |   50 + Siart Mathau (Siart Gantt,...)   |   40+ Ymarferol Fformiwlâu (Cyfrifwch oedran yn seiliedig ar ben-blwydd,...)   |   19 mewnosod offer (Mewnosod Cod QR, Mewnosod Llun o'r Llwybr,...)   |   12 Trosi offer (Rhifau i Eiriau, Trosi arian cyfred,...)   |   7 Uno a Hollti offer (Rhesi Cyfuno Uwch, Celloedd Hollt,...)   |   ... a mwy

Supercharge Eich Sgiliau Excel gyda Kutools ar gyfer Excel, a Phrofiad Effeithlonrwydd Fel Erioed Erioed. Kutools ar gyfer Excel Yn Cynnig Dros 300 o Nodweddion Uwch i Hybu Cynhyrchiant ac Arbed Amser.  Cliciwch Yma i Gael Y Nodwedd Sydd Ei Angen Y Mwyaf...

Disgrifiad


Mae Office Tab yn dod â rhyngwyneb Tabbed i Office, ac yn Gwneud Eich Gwaith yn Haws o lawer

  • Galluogi golygu a darllen tabbed yn Word, Excel, PowerPoint, Cyhoeddwr, Mynediad, Visio a Phrosiect.
  • Agor a chreu dogfennau lluosog mewn tabiau newydd o'r un ffenestr, yn hytrach nag mewn ffenestri newydd.
  • Yn cynyddu eich cynhyrchiant 50%, ac yn lleihau cannoedd o gliciau llygoden i chi bob dydd!
Comments (12)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hey thanks was finding this for years.
This comment was minimized by the moderator on the site
awesome!!!!!!
This comment was minimized by the moderator on the site
awesome!!!!!!
This comment was minimized by the moderator on the site
Does this code have to be applied to each excel file separately or can the macro be saved within excel to be toggled on/ off whenever a new Excel workbook is open?
This comment was minimized by the moderator on the site
Hello

It seems that xHwnd defined to store Application.hWnd before calling SetWindowPos as below:

xHwnd = Application.hWnd
Call SetWindowPos(xHwnd, xStype, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE)

Thanks
This comment was minimized by the moderator on the site
Absolute genius. Exactly what I needed. Thanks!!!
This comment was minimized by the moderator on the site
Thanks so much for this! I needed to keep my automated system stats sheet up at all times while I did other things based on what it was showing me. Very helpfull! :D
This comment was minimized by the moderator on the site
Thanks .. God Bless..!
This comment was minimized by the moderator on the site
Thanks for this. Very helpful when transposing data from multiple systems onto a spread sheet. Appreciate the code!
This comment was minimized by the moderator on the site
Thanks for the help!!! I had to use this as a workaround because you cant have two workpages open at the same time. Appreciate you sharing your code :)
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations