Word Document Properties


Chapter 11: VBA Programming with XML



Download 8,82 Mb.
Pdf ko'rish
bet201/207
Sana16.03.2022
Hajmi8,82 Mb.
#496217
1   ...   197   198   199   200   201   202   203   204   ...   207
Bog'liq
VBA For Dummies 5th Ed.pdf ( PDFDrive )

Chapter 11: VBA Programming with XML
17_046500 ch11.qxp 12/5/06 5:37 PM Page 243


information. Database managers such as Access always use a schema (you
define it when you create a table), but other Office applications don’t
because you normally don’t need to organize the information by using a
schema. Figure 11-4 shows a typical worksheet. The data structure is proba-
bly obvious to you because each of the columns is named, but the computer
doesn’t have a clue to what that data means.
An 
XML Schema Definition
(XSD) file contains a description of the information
that you want to export from or import to an Office application. It doesn’t
matter which application you use because, at some point, you have to create
an XSD file to perform pure XML data transfers. Listing 11-1 shows an example
of an XSD file that describes the data shown in Figure 11-4. (You can find the
source code for this example on the Dummies.com site at 
http://www.
dummies.com/go/vbafd5e
.)
Listing 11-1
Creating an XSD Description


















Figure 11-4:
Understand-
ing data
formats is
easy for you
but hard 
for the
computer.
244
Part III: Expanding Your VBA Horizons 
17_046500 ch11.qxp 12/5/06 5:37 PM Page 244


This is yet another XML file, so it begins with the standard XML processing
instruction. The second line contains the URL for the XSD file definitions. You
must include this line in all your XSD files. You can include other information,
such as a personal namespace, as part of this header, but it’s all optional. See
the tutorial at 
http://www.w3schools.com/schema/default.asp
for
additional information.
The structure of your information comes next. Chapter 9 describes how VBA
collections work. The tags that XSD relies on to define your data act much
like a collection. The top element, 
Items
, defines the collection name. The

tag tells the XSD parser that you’re defining something
other than a string or an integer. You use the 

tag to tell the
XSD parser that the next set of elements must appear in the order shown and
that the parser can’t skip any of the elements.
The 

tag shows
how to create an individual item within an XSD collection. The two things
that set this tag apart from the 

tag is that it appears within the

tag and also uses the special 
maxOccurs
attribute. Notice that the
maxOccurs
attribute is defined as 
unbounded
(unlimited) so that the 
Items
collection can contain as many individual 
Item
elements as needed.
The 

tag is also a complex type and requires elements in a specific
sequence. This time, the individual elements are simple types. The 

tag is a string, but the 

and 

tags are both in decimal nota-
tion. XSD doesn’t currently support a currency type, so your best choice is to
use a decimal to ensure that the XSD parser preserves the accuracy of the
data that you transfer.
Defining XSD to worksheet linkage
Writing the XSD file creates a definition that you can use to work with data in
Excel. However, you still haven’t created linkage between the XSD file and the
Excel document. (You should perform this task by using a document tem-
plate in Word — see the upcoming “Creating a Simple Word XML Document”
section for details.) Here’s how to create linkage in Excel 2007:

Download 8,82 Mb.

Do'stlaringiz bilan baham:
1   ...   197   198   199   200   201   202   203   204   ...   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