Word Document Properties


Part II: Learning the Ropes



Download 8,82 Mb.
Pdf ko'rish
bet127/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   123   124   125   126   127   128   129   130   ...   207
Bog'liq
VBA For Dummies 5th Ed.pdf ( PDFDrive )

Part II: Learning the Ropes 
11_046500 ch06.qxp 12/5/06 5:35 PM Page 142


enough to hold the number required to express the amount of available drive
space. Office 2007 has updated variables wherever the old variable isn’t large
enough to hold the expected data values. Consequently, you might find that
some of your old macros have broken because the data type has changed.
Because the drive doesn’t have enough space, the code displays an error
message. The message shown in the code might seem long and complicated,
but it provides all the information needed to make a decision. It tells what’s
wrong, provides you with a choice of actions, and contains specifics about
the amount of space needed. Notice the use of the 
Format
function for the
message. It shows how to use a custom formatting string to display the free
space with comma separators but without a decimal point.
If you say that you want to fix the drive space error, the code presents a mes-
sage box that tells you to click OK when it’s okay to make the change again.
The code uses the 
GoTo
statement to redirect execution to the drive space
check again.
On the other hand, if you decide not to fix the error, the program tells you the
result of the action. It then exits the 
Sub
without doing anything else. This
step is important. Otherwise, the program attempts to save the file, and the
error occurs.
Understanding error handlers
Error handlers are your option of last resort in dealing with bugs. You use an
error handler to work with any errors that you can’t trap. The important thing
to remember is that the error has happened — you can’t prevent it at this
point. The best that you can do is to display a message box saying that the
error happened and to tell whether your program can recover from the error.
When your program can’t recover, it should fail gracefully. However, failing
gracefully shouldn’t be a standard option — always try to recover from the
error. A program that fails gracefully performs the following tasks:
The program doesn’t rely on the standard VBA message. It uses a
custom message that contains detailed failure information instead.
The user is always informed about the consequences of the failure, pos-
sible fixes, and whom to contact (when necessary).
The reporting information should also appear in the Windows Event Log
when necessary to ensure that the administrator sees the error. VBA
doesn’t support this feature directly.
If possible, the program includes you as part of the reporting loop so
that you can keep track of bugs in your application.
143

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   123   124   125   126   127   128   129   130   ...   207




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish