Word Document Properties


Chapter 10: Working with Disk Files



Download 8,82 Mb.
Pdf ko'rish
bet197/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   193   194   195   196   197   198   199   200   ...   207
Bog'liq
VBA For Dummies 5th Ed.pdf ( PDFDrive )

Chapter 10: Working with Disk Files
16_046500 ch10.qxp 12/5/06 5:36 PM Page 237


Listing 10-4
(continued)
‘ Determine whether there is data in the file.
If Output.AtEndOfStream Then
‘ Tell the user the file is empty.
OpenReadConfig = False
Else
‘ Tell the user the file was opened successfully.
OpenReadConfig = True
End If
End Function
The function begins by creating a path to the user’s settings. It then checks
for the existence of the user file. Notice that in this case the function exits
rather than creates the file. In many cases, you don’t want to create a file
when you’re opening it for reading.
When the file does exist, the code opens the file for reading by using
FS.OpenTextFile()
. Notice the special 
ForReading
argument. If you
don’t specify this value, 
FS.OpenTextFile()
uses the default settings.
The next check ensures that the data file actually contains information. When
Output.AtEndOfStream
is true, the file is empty and the function returns
to the caller with 
False
. Otherwise, the return value is 
True
.
238
Part III: Expanding Your VBA Horizons 
16_046500 ch10.qxp 12/5/06 5:36 PM Page 238


Chapter 11
VBA Programming with XML
In This Chapter
Defining the features of Word Markup Language (WordML)
Designing your first XML document
Working with XML data
Creating an XML document
Using eXtensible Style Language Transformation (XSLT) to modify presentation
T
he 
eXtensible Markup Language
(XML) is a special way of marking text
so that it contains both information and context. Using this technique
means that the recipient knows not only the information but also the mean-
ing behind the information. For example, if you see 
12.99
in a text file, you
don’t know what it means. It’s a number, but that’s all you know. However, by
adding context to the number, you can say that the number means 12 dollars
and 99 cents.
XML began on the Internet as a means to make information exchange possi-
ble. You can use XML to exchange data with others, even if they don’t have
the same program or even the same operating system that you do. The only
requirements are that both machines can read text and that you have a pro-
gram that can understand the XML.
This chapter describes how you can use XML to enhance the documents that
you create with Office. Although you can manually perform many of the tasks
that I describe in this chapter, using VBA to perform them makes sense
because the actions are both lengthy and repetitive. In addition, you must
perform some XML tasks, such as defining precise output content, with VBA
because there’s no manual alternative. This chapter also shows how to write
programs that can interpret the XML. This final task is important because
you can then use XML to send information in any format needed.
17_046500 ch11.qxp 12/5/06 5:37 PM Page 239


Comparing WordML with Saved XML
When you save a Word document either manually or programmatically, you
can save it as an XML document. However, not all XML documents are cre-
ated equal. Figure 11-1 shows a Word Save As dialog box set up to save a doc-
ument as XML.

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   193   194   195   196   197   198   199   200   ...   207




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©www.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