您的位置:首页 >> 数据库 >> Sybase >> 正文
Sybase RSS
 

PowerBuilder with Word 97

http://www.rdxx.com 06年06月13日 12:06 互连网 我要投稿

关键词: PowerBuilder , Word , IT , UI
SUMMARY: This document reviews how to find the correct Visual Basic for Application syntax needed in Word and how to convert it into the correct PowerBuilder syntax.
Includes:
- Code examples to see the PowerBuilder syntax for Word 8 OLE automation.
- Incomplete list of VisulaBasic constants and their values for PowerBuilder
Document ID: 47980 Last Revised: 10/28/99
Topic: App Development Document Type: TechNote
Product: PowerBuilder Version: 7.0; 6.0; 5
Platform: PC Operating System: Windows 95, Windows NT, Windows 98

Document:

  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.
Sub Macro1()
    ' VB Syntax in a macro
    ' see hint a.
    Selection.Information(wdWithInTable)

    ' see hint b.
Selection.MoveLeft Unit:=wdCharacter, Count:=5

' function without values
Selection.TypeBackspace

End Sub
From the VBAWRD8.HLP file, here is the definition of the MoveLeft() function used in the macro:

Selection.MoveLeft(Unit, Count, Extend)

Unit optional Variant: wdCell, wdCharacter, wdWord or wdSentence. Default = wdCharacter.
Count optional: . Number of Units to move. Default = 1.
Extend optional: wdMove or wdExtend

Here is the syntax to call the MoveLeft() function

// PB syntax
ole_object.selection.Information[12]
ole_object.selection.MoveLeft(1,5,1)
ole_object.selection.TypeBackspace()

  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.

Sub Makro1()
' this is a small messagebox to find out the integer
' value of an enumerated datatype in Word.
' in this case the value 5
Answer = MsgBox(wdLine, 0)
End Sub

  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

共2页  1 2


 
 
标签: PowerBuilder , Word , IT , UI 打印本文
 
 
  热点搜索
 
 
 



Valid XHTML 1.0 Transitional
Copyright ©2005 - 2008 Rdxx.Com,All Rights Reserved
收藏本页
收藏本站