Word Document Properties


Chapter 3: Writing Structured VBA Programs



Download 8,82 Mb.
Pdf ko'rish
bet72/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   68   69   70   71   72   73   74   75   ...   207
Bog'liq
VBA For Dummies 5th Ed.pdf ( PDFDrive )

Chapter 3: Writing Structured VBA Programs
08_046500 ch03.qxp 12/5/06 5:34 PM Page 73


Listing 3-3
Using a Function to Retrieve Document Information
Public Sub GetSummary2()
‘ Declare a string to hold the output information.
Dim DocumentData As String
‘ Store the name of the information.
DocumentData = “Author Name: “
‘ Get the author name.
DocumentData = DocumentData + GetDocProperty(“Author”)
‘ Add an extra line.
DocumentData = DocumentData + vbCrLf
‘ Store the name of the information.
DocumentData = DocumentData + “Company: “
‘ Get the company name.
DocumentData = DocumentData +
GetDocProperty(“Company”)
‘ Display a message box containing the property value.
MsgBox DocumentData, vbOKOnly, “Summary”
End Sub
Private Function GetDocProperty(Name As String) As String
‘ Declare a DocumentProperty object to hold the
‘ information.
Dim MyProperty As DocumentProperty
‘ Set the DocumentProperty object equal to the author
‘ information.
Set MyProperty = _
ActiveWorkbook.BuiltinDocumentProperties(Name)
‘ Return the information.
GetDocProperty = MyProperty.Value
End Function
Listing 3-3 begins with 
GetSummary2
. Much of what you see looks simi-
lar to previous examples. However, notice how the code works with
DocumentData
. The example builds the text output by adding the previous
content of the string to itself. So, first 
DocumentData
contains 
“Author
Name: “
, and then you add the actual author name to it by using
GetDocProperty
.
Another new addition is the use of a constant. The 
vbCrLf
constant contains
special characters that act the same as when you press Enter at the end of a
line of text in a word processor.
74

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   68   69   70   71   72   73   74   75   ...   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