Уважаемый посетитель!
Так как в Вашем браузере запрещено использование JavaScript для web-страниц, меню сайта Вам не доступно.
Для навигации по сайту используйте пожалуйста карту сайта.

Сделать стартовой Добавить в избранное Обратная связь

партнеры

SQL.RU

Детский Дворик - Портал детских фотографий

ГавГав.Инфо - портал для собаководов-любителей и профессиональных кинологов

информация

реклама

Русская версия
« Оглавление Глава 2 »

Глава 1

PowerBuilder OLE Programming with Microsoft Word '97 (Word 8)

1. How to find the correct Visual Basic for Applications (VBA) syntax needed in Word and how to convert it into the correct PowerBuilder syntax

With Word 8 / Office 97, Microsoft changed the way applications communicate with Word via OLE. Old WordBasic syntax may not work properly and converting them to VBA equivalents may be required.

1.1 Use the Word macro Editor

An easy way to determine the VBA functions and their syntax by using the macro editor which is integrated in Word. To obtain the VBA functions turn on the macro recording in Word, perform the tasks you wish the macro to perform (ie. Highlight some text), and then turn off the recording. With ALT + F11 you are able to open the macro editor and see the syntax used by Word.

To get a complete description of a function and to see the complete syntax you can use the help file VBAWRD8.HLP which is available through a custom installation of Word (you must specify to install this help file during the installation process, it is not installed by default). Here you will find information regarding the functions you can use in Word and their VBA and WordBasic syntax. Furthermore you will be instructed which functions you can use with Word 8.

1.2 Convert VB Syntax to the PowerBuilder Syntax
Hints:
a. PowerBuilder uses square brackets for array indices
b. Functions with several values are separated by comma between round brackets

Convertion example :
Here you see a macro recorded with the macro editor in Word.

From the VBAWRD8.HLP file, here is the definition of the MoveLeft() function used in the macro:
Here is the syntax to call the MoveLeft() function
The question is now: what value does the constants "wdWithInTable", "wdCharacter" contain? These are only known to MS Word which prevents PowerBuilder from having any knowledge about them. However each constant is associated with a value which can be used in its place. In general most of them are integers and you can display them in a message box within the macro to determine their actual value i.e.

Alternatively, Micorosoft's support website has a technical article which documents all of the constants and their numerical equivalents that may be found in Microsoft Office.
The article is ID# Q112671.

In PowerBuilder, you would pass the actual value of the Word constant to the function. You can also declare a constant in PowerScript and associate it with the same value; when calling the Word function, pass it the constant you declared instead of the actual value. This allows you to make global changes easily to your code if Microsoft decides to change what the value of the Word constant in future releases.

Under section 3. you find a list with common constants and their numeric equivalents.

1.3 The Word Object Model
If you open VBAWRD8.HLP file you will find the hierarchy of the Microsoft Word Objects. Through OLE, you can traverse the hierarchy by using PowerBuilder's dot notation.

Some common objects/methods and attributes are:
Application, System, MailMessage, Selection, Selection.Font, Selection.Pagesetup, Selection.Border, Selection.Words, ActiveDocument, ActivePrinter, Checkspelling, CheckGrammar ...
Several methods and attributes of the Application object can be used without specifying the "application" constant.
For example the ActiveDocument or Documents are considered global objects within Word. Instead of writing:
you can write:


Below you'll find some code examples using the objects, methods and attributes of Word.

2. Code Examples

For all following examples the PowerBuilder OleObject is assumed to have already been create dynamically with:

If you use the PowerBuilder OLE control (ole_1) you must remember to include the "object" constant before accessing Microsoft Word objects, properties, and functions.

or

2.1 Connect to Word 8

2.2 bookmarks

2.3 spellchecker and grammarchecker method

2.4 How should the text look like

2.5 Step through and find the text

2.6 Activate and access a Word blob in a datawindow
If you have an OLE column specified in a datawindow you must activate the column to and then associate it with an OLEObject to get access to its properties and functions:

3. Parital Listing of Visual Basic for Applications Constants and their Values for PowerBuilder

The following is a list of some of the VBA constants that may be found within Microsoft Word. For a comprehensive listing, please visit the Microsoft Support Website and search their knowledge base for technical article Q112671.



Последнее обновление: 11.08.2016
реклама
ссылки


Продвижение сайтов

Биржа ссылок

статистика

Яндекс цитирования

(c)2002-2024 Ikar
Ikar Home Center
ICQ: 167220388
На сайте могут быть опубликованы рекламные материалы и ссылки. Всю ответственность за содержание рекламных материалов, текстов ссылок и контент рекламируемых сайтов несет рекламодатель.
hosted on pets-tree
.