272 Chapter 6
Creating Reports Easily Using ActiveX
Using MS Word for Agilent VEE Reports
8. Add three more Formula objects and one If/Then/Else object,
configure, and connect them as shown in Figure 6-17.
Set Doc =
App.Documents.
Add();
Adds a Document in MS Word and assigns it
to the
Object variable Doc.
Note: In the Excel example, Excel was started
with a blank worksheet using
CreateObject(Excel.Sheet). In this
example, Word is started and the method
Add() adds an empty Document to it. Either
application can be created either way.
Doc.Activate(); Activates the Document above.
Set Wnd = App.Active
Window;
Takes the document in the active window and
assigns it to the
Object variable Wnd.
Set Sel = App.Selection; Puts focus (selection) into the document and
assigns this to the
Object variable Sel. This
allows you to insert text.
Wnd.View.Type = 3; Specifies the type of window for displaying
the document. The 3 indicates a normal
window size. A 1 would iconize the window.
Note: The 3 is used here instead of the constant
wdPageView because the constant is missing
from the Office 2000 Type Library.
Sel.TypeText(*** Test
Results ***),
Sel.TypeParagraph();
Puts the title
*** Test Results *** in the
document and issue a carriage return/line feed.
Set Bmp = Doc.Shapes.
AddPicture(FileName);
Puts the
panel.bmp bitmap into the document
and assigns this call in the
Shapes Class to
the
Object variable Bmp.
Sel.TypeParagraph();
Sel.InsertDateTime
(M/d/yy h:mm:ss
am/pm, 0);
Puts a time stamp in the document.