Skip i'r prif gynnwys

Sut i greu amserydd blwch neges i gau'r blwch negeseuon yn awtomatig ar ôl amser penodol yn Excel?

Awdur: Siluvia Wedi'i Addasu Diwethaf: 2022-02-18

Wrth ddefnyddio llyfr gwaith Excel, efallai y byddwch yn aml yn defnyddio sgriptiau VBA i ddatrys problemau. A bydd rhai blychau neges yn ymddangos yn ystod y sgript. Mewn rhai achosion, byddwch am i rai blychau negeseuon penodedig gau yn awtomatig ar ôl amser penodol, yn hytrach na'u cau â llaw. Yn yr erthygl hon, byddwn yn dangos dull i chi o greu amserydd blwch neges i gau'r blwch neges yn awtomatig ar ôl amser penodol yn Excel.

Creu amserydd blwch neges i ddiswyddo blwch negeseuon ar ôl amser penodol


Creu amserydd blwch neges i ddiswyddo blwch negeseuon ar ôl amser penodol

Yma yn darparu templed sgript VBA i chi greu amserydd blwch neges.

Gan dybio eich bod yn rhedeg sgript VBA i symud rhesi yn seiliedig ar werth cell. Ar ôl gorffen symud, mae angen blwch negeseuon arnoch i'w agor i ddweud wrthych fod y llawdriniaeth yn llwyddiannus a bod angen cau'r blwch neges hwn yn awtomatig ar ôl 4 eiliad (gweler y llun isod). Dilynwch y camau isod.

1. Agorwch y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr, cliciwch Mewnosod > Modiwlau, ac yna mewnosodwch y cod VBA yr ydych am ei ddefnyddio i symud rhesi yn seiliedig ar werth celloedd.

2. Copïwch y cod VBA 1 canlynol a'i roi cyn y cod yr ydych am ei weithredu. Gweler y sgrinlun isod:

Cod VBA 1:

Private Declare PtrSafe Function CustomTimeOffMsgBox Lib "user32" Alias "MessageBoxTimeoutA" ( _
            ByVal xHwnd As LongPtr, _
            ByVal xText As String, _
            ByVal xCaption As String, _
            ByVal xMsgBoxStyle As VbMsgBoxStyle, _
            ByVal xwlange As Long, _
            ByVal xTimeOut As Long) _
    As Long

3. Copïwch y cod VBA 2 isod a'i roi cyn y llinell "End Sub" o'r cod yr ydych am ei weithredu.

Cod VBA 2:

 Call CustomTimeOffMsgBox(0, "Moved successfully. This message box will be closed after 4 seconds", "Kutools for Excel", vbInformation, 0, 4000)

Nodyn: Gallwch newid cynnwys y blwch neges, ac amser arddangos y blwch deialog yn ôl eich anghenion.

4. ar ôl rhedeg y cod i gyflawni'r llawdriniaeth, bydd blwch neges pop i fyny ac yna cau yn awtomatig ar ôl amser penodol (yn yr achos hwn yw 4 eiliad).


Erthyglau perthnasol:

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 (8)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Ufff... great!!... very good... thank you
This comment was minimized by the moderator on the site
Ufff... buenisimo!!... muy bien... gracias
This comment was minimized by the moderator on the site
Hi. Thanks for this - it's really useful. Is there any way to stop Excel (VBA) chiming when the box appears? I need to use this as a repeatedly looping message in a piece of code but aside from turning the volume down I don't know how to stop the warning sound appearing everytime the box appears? Thanks.
This comment was minimized by the moderator on the site
Hi thebankman,This is the default application system sounds in windows. You can turn it off as shown in the screenshot below.
This comment was minimized by the moderator on the site
Thanks Crystal. Much appreciated
This comment was minimized by the moderator on the site
Hi. is there any way to stop Excel (VBA) chiming when the box appears? I need to use this as a repeatedly looping message in a piece of code but aside from turning the volume down I don't know how to stop the warning sound appearing everytime the box appears? Thanks.
This comment was minimized by the moderator on the site
It is really nice, but on my codes I'm using the "GetAsyncKeyState" function to recognize the entry status for my data (using an scan gun) and the "MsgBoxTimeout" function is affecting the "GetAsyncKeyState" function. Without the "MsgBoxTimeOut" everything is working normal, when I include it, is like disactivate the "GetAsyncKeyState" function, but both not want to work together. Have you any suggestion?
This comment was minimized by the moderator on the site
You are just perfect... :lol: :lol: :lol: 8) 8) 8)
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations