© 2008 by CapeSoft Software (Pty) Ltd
www.capesoft.com
     



Microsoft Word Functionality



Contents
  Templates
  Add_MSWord_Object
  Word_SpellChecking
 
 

Classes
  The oiWord Class
        Methods
        Properties (New)
        Equates
 

Dll Functions
 
Useful References

  How to add Spell Checking to your Applications
  Tips & FAQs

  About using "Mail Merge"
  MS Word Underline Styles
  MS Word Textures

 

Return to the Main Office Inside Docs
     

Templates

Add_MSWord_Object
  Summary  
Procedure Extension Template
Add an MS Word object to a procedure
Optional
 
What does it do?
This template is used to add MS Word functionality to a procedure in your app.  We are still developing it and adding functionality to it, more info will come later.
 
Prerequisites
You need to have added the Activate_Office_Inside global extension template before you can add this template to a procedure. If you are using Legacy and would like to use the Editable Report Word and Excel templates you need to ticked on "Enable the use of ABC classes" checkbox under Global Settings on the Classes tab.
 
How do I implement it?
  1. Select the procedure which you want to add this template to.
  2. Select "Properties..." from the "Edit" menu
  3. Click the "Extensions" button
  4. Click on the "Insert" button to add a new extension template
  5. Select "Add_MSWord_Object" ( found under the "Class OfficeInside" group )
  6. Click "Select", then "OK", then "OK" again...

What are my options?

General Tab:

Object Name:

This is the name of the Office Inside object that this template will create and implement.  Typically this would default to 'MyWord1', but you can change it if you would prefer to call the object something else.

 

     

 

Word_SpellChecking
  Summary  

Extension Template
Add Spell Checking Support to a window
Optional

Important for Clarion 5.5 users
The standard spell checking template will not work on C55 RTF controls, in order to spell check RTFControlClass controls you need to populate the 'Office Inside Spell Check for C55 RTF' control template onto your window. This adds a button that when pressed will perform spell checking the the RTF control. See the section on C55 RTF Controls below.

Important for Clarion 6 users
A Checkbox has been added to the Global Extension that should be checked in order to use spell checking on a Clarion 6 RTF control. See the section below on C6 RTF controls for instructions on changing the required RTF class property.
 

What does it do?
This template adds Spell Checking support to a window.  Simply add it to a window procedure and you will be able to press F7 (or which ever key you select) and the currently selected field will be "spell-checked".
 
Prerequisites
  1. You need to have added the Activate_Office_Inside global extension template to your application, and...
  2. you need to have added the Add_MSWord_Object extension template to the procedure that you want to add this template to.
  3. For C55 RTF controls you need to add a "Spell Check RTF" button for each RTF control you wish to spell check. See the section on C55 RTF Controls below.
  4. In order to support RTF controls in Clarion 6 you need to make a change to the a property of the RTF Class. See the section on C6 RTF controls below.
How do I implement it?
  1. Select the procedure which you want to add this template to.
  2. Select "Properties..." from the "Edit" menu
  3. Click the "Extensions" button
  4. Click on the "Insert" button to add a new extension template
  5. Select "Word_SpellChecking" ( found under the "Class OfficeInside" group )
  6. Click "Select", then "OK", then "OK" again...

What are my options?

Keycode to alert for:

This is the key that Office Inside will watch for, which will invoke the Spell Checker.  Typically this defaults to 'F7Key'.

 

C55 RTF Controls

For Clarion 5.5 you need to populate the 'Office Inside Spell Check for C55 RTF' control template onto your window for each RTF control. You must have added a Word object to your procedure in order to use this control template.

  1. Open the procedure that contains the RTF control
  2. Choose Populate->Control Template from the menu
  3. Select 'Office Inside Spell Check for C55 RTF' from the list and click OK
  4. A button control is populated onto the window. Right click on the button and choose "Actions"
  5. Fill in the "Office Inside Word Object" field with the name of the Word object that you added to the procedure. For example: MyWord1

You can optionally specify the maximum size for the spelling checking string (this defaults to 256K), and whether or not a message should be shown to the user when spell checking is complete (defaults to on)

Clarion RTF Controls

A Checkbox has been added to the Global Extension that should be checked in order to use spell checking on a Clarion 6 RTF control. This has been added becuase in order to use spell checking on Clarion 6 RTF controls the RtfControlClass needs to have a line modified. If you have ticked this box to enable spell checking of Clarion 6 RTF controls, then open the rtfctl.inc file in your Clarion6\libsrc directory and change the lines that reads:

CtlRTF SIGNED,PROTECTED

to:

CtlRTF SIGNED!,PROTECTED

The PROTECTED attribute needs to be commented out in order to allow Office Inside to identify which control the object is associated with.

     

Classes

This section describes the various classes which make up "Office Inside".  Each class contains methods and properties, which are documented below.  Each method is documented by giving the method name, the parameters, an example of how to code the method, a list describing what the method does, and additional comments below.

The oiWord Class - Introduction

The oiWord class is a "wrapper" class, which is used by the templates and by other classes as the "communication" layer between Office Inside and MS Word.  Should you wish to write code which communicates "directly" with MS Word, this is the class you're looking for.

 

oiWord Class Methods
 

New Methods (also listed below)

  SpellCheckString Spell checks a passed string
  SpellCheckHtml Spell checks HTML contents (ignores tags, script etc.)
  SpellWord Spell checking callback
Protect Enables document protection
  Unprotect Removes document protection

Class Methods

  AlignCenter Align the current selection centre on the page
  AlignJustify Set the alignment for the current selection to Justified (tries to stretch the text to the edges of it's container)
  AlignLeft Set the alignment for the current selection to left aligned
  AlignRight Set the alignment for the current selection to left aligned
  Bold Make the selected text bold
  CentimetersToPoints Convert a number from Centimetres to Points
  CheckGrammar Check the Grammar of a passed string
  CheckSpelling Check the Spelling of a passed string
 

CheckSpelling_AddToIgnoredWords

Adds a word to the Ignored list when spell checking
  CheckSpelling_IsWordIgnored Checks if a word is in the Ignored list when spell checking
  CloseDoc Closes the current document
  CloseFooter Closes the footer if it is open (returns to editing the main document)
  CloseHeader Closes the header if it is open (returns to editing the main document)
  Copy Copies the current selection to the clipboard
  CountCharacters Counts the number of characters in the current selection
  CountOpenDocs Counts the number of open documents in this instance of Word
  CountTables Count the number tables in the current document
  Cut Cuts the current selection out of the document and places it on the clipboard
  ErrorTrap Called when an error occurs
  FindText Searches the document for a specified string
  GetFontColor Gets the font color of the current selection
  GetFontName Gets the font name of the current selection
  GetFontNames Fills a queue with all available fonts
  GetFontSize Gets the font size of the current selection
  GetInfo Retrieves various properties about Word and the document
  GetNameOfDictionary Gets the currently selected dictionary name
  GetSelectionEnd Returns the position that the current selection starts at
  GetSelectionStart Returns the position that the current selection ends at
  GetText Returns the text in the current selection
  GotoEndOfDoc Moves the cursor to the end of the document
  GotoItem Moves the cursor to the specified item (and optionally extends the current selection)
  HideToolbar Hides the Toolbar in Word
  InchesToPoints Converts a number from inches to points
  Init Initialises the Word object and start Word if it is not already started.
  InsertBreak Inserts a break in the document.
  InsertPicture Inserts a picture in the document.
  InsertTable Inserts a table in the document.
  InsertText Inserts text in the document.
  InsertTextbox Inserts a text box in the document.
  Italic Makes the font of the current select to italic.
  Kill Kills the Word object
  LinesToPoints Returns the height of the passed number of lines in the document in points
  MailMergeGetRecord Gets the next record for the mail merge
  MailMergeRun Starts the mail merge
  MailMergeSetDataSource Sets the data source for a mail merge
  MillimetersToPoints Converts from millimetres info points
  MoveDown Moves the cursor down
  MoveLeft Moves the cursor left
  MoveRight Moves the cursor right
  MoveUp Moves the cursor up
  NewDoc Creates a new document
  NextLine Moves to the next line
  OpenDoc Opens an existing document
  OpenFooter Opens the document footer for editing
  OpenHeader Opens the document header for editing
  Paste Pastes the contents of the clipboard into the document
  PicasToPoints Converts from Picas to Points
  PixelsToPoints Converts from Pixels to Points
  PointsToCentimeters Converts from Points to Centimetres
  PointsToInches Converts from Points to Inches
  PointsToLines Converts from Points to Lines
  PointsToMillimeters Converts from Points to Millimeters
  PointsToPicas Converts from Points to Picas
  PointsToPixels Converts from Points to Pixels
  PrintDialog Displays a Print dialog box
PrintMe Prints the current document
  PrintOut Epanded Print method that exposes all Word print settings
  PrintPreview Display a Print Preview of the document
  Protect Turns on document protection
  Redo Redoes an action and has been Undone
  ReplaceText Replaces a specified sting or all occurances thereof
  RestoreSnapShotOfWindowPos Restores the window size and position to that which was saved
  Save Saves the current document
  SaveAs Save the document as a new file
  SetBackground Sets the background color
  SetFontColor Sets the currenly used Font color
  SetFontName Sets the currenly used Font name
  SetFontSize Sets the currenly used Font size
  SetPageView Change the type of page view
  SetParagraphFormatting Sets the paragraph formatting for the current selection
  SetScreenUpdating Turns screen updating (redraw) on or off
  SetSelection Sets the current selection in the document
  ShowMessage Displays a message to the user
  ShowToolbar Unhides the toolbar in Word
  ScreenRefresh Redraws the Word window if screen updating is off
  SpellCheckString Spell checks a passed string
  SpellCheckHtml Spell checks HTML contents (ignores tags, script etc.)
  SpellWord Spell checking callback
  TableAutoFormat Automatically formats a table using one of the styles that Word provides/
  TableCountColumns Counts the number of columns in a table
  TableCountRows Counts the number of rows in a table
  TableGetCellBackgroundColor Gets the background color of the current cell
  TableGetCellForegroundColor Gets the foreground color of the current cell
  TableGetCellTexture Gets the textre selection for the current cell
  TableGetColumnWidth Gets with width of the selected column in a table
  TableGetInsideBordersLineStyle Gets the border line style for a table
 

TableGetOutsideBordersLineStyle

Gets the border line style for a table
  TableInsertRowAtEnd Adds a row to the end of a table
  TableMergeSelectedCells Merges the selected cells in a table
  TableSetCellAlignCenter Sets the cell alignment to center
  TableSetCellAlignJustify Sets the cell alignment to justify
  TableSetCellAlignLeft Sets the cell alignment to left
  TableSetCellAlignRight Sets the cell alignment to right
  TableSetCellBackgroundColor Sets the cell background color
  TableSetCellBold Sets the Bold attribute of the current cell's text
  TableSetCellFontColor Sets the font color for the current cell's text
  TableSetCellFontName Sets the font face for the current cell's text
  TableSetCellFontSize Sets the font size for the current cell's text
  TableSetCellForegroundColor Sets the foreground color for the current cell (for patterns)
  TableSetCellItalic Makes text in the current cell italic
  TableSetCellTexture Sets the texture (image) used for the current cell background
  TableSetCellUnderline Sets text in the current cell to underlined
  TableSetColumnWidth Sets the width of a column in a table
  TableSetInsideBordersLineStyle Sets the border line style for a table
  TableSetOutsideBordersLineStyle Sets the border line style for a table
  TableUpdateAutoFormat Updates the automatic formatting and applies it to any new rows or columns that may have been added and not have had the formatting applied.
  TableWriteToCell Writes text into a cell in a table
  TakeEvent Called each time an event occurs in Word if Event Callbacks are on
  TakeSnapShotOfWindowPos Saves the current state of the Word window, allowing it to be restored later
  Underline Sets the current selection's underline attribute
  Undo Undoes the last action
  Unprotect Turns of document protection
  Update Updates a property of the Word application or the current document
 
     

 


AlignCenter     ( ) ,byte,proc
MyWord.AlignCenter ()
TempByte = MyWord.AlignCenter ()

  • Centers the currently selected text on the page
  • Returns true (1) if no problems were experienced

AlignJustify     ( ) ,byte,proc
MyWord.AlignJustify ()
TempByte = MyWord.AlignJustify ()

  • Justifies the currently selected text
  • Returns true (1) if no problems were experienced

AlignLeft     ( ) ,byte,proc
MyWord.AlignLeft ()
TempByte = MyWord.AlignLeft ()

  • Aligns the currently selected text to the left.
  • Returns true (1) if no problems were experienced

AlignRight     ( ) ,byte,proc
MyWord.AlignRight ()
TempByte = MyWord.AlignRight ()

  • Aligns the currently selected text to the right.
  • Returns true (1) if no problems were experienced

Bold     ( byte pOption=oiw:BoldToggle ) ,byte,proc
MyWord.Bold (oiw:BoldOn)
TempByte = MyWord.Bold (oiw:BoldOn)

  • Makes text bold / not bold
  • pOption can be one of the following equates:
    • oiw:BoldOn
    • oiw:BoldOff
    • oiw:BoldToggle
  • Returns true (1) if no problems were experienced

CentimetersToPoints     ( string pCentimeters ) ,string
loc:Points = MyWord.CentimetersToPoints(1.5)
MyWord.Update(oiw:PageLeftMargin, MyWord.CentimetersToPoints(1.5))

CheckGrammar     ( *string pText ) ,byte
TempByte = MyWord.CheckGrammar (StringVar)
  • Checks the grammar in the text passed as pText.
  • Returns true (1) if there were no grammar errors, false (0) if there were errors, and a value greater than 1 if an internal error occurred.
  • ( Current limitation of 1000 characters )

CheckSpelling     ( string pText, byte pSilent ) ,byte,proc
StringVar = 'This is spelld wrongg'
TempByte = MyWord.CheckSpelling (StringVar)

if MyWord.CheckSpelling (loc:Var1, false, false) = true
  loc:Var1 = MyWord1.TempCString
  ...

  • Checks the spelling in the text passed as pText.
  • Returns true (1) if there were no spelling errors, false (0) if there were errors, and a value greater than 1 if an internal error occurred.
  • When you call this method, the queue (property) called self.WordsQ is populated with any spelling suggestions.
  • ( Current limitation of 1000 characters )
  • ( This documentation must be redone )

CheckSpelling_AddToIgnoredWords     ( string pText ) ,byte,proc
MyWord.CheckSpelling_AddToIgnoredWords ('CapeSoft')
  • Used by the templates when spell checking.  Adds the word passed as pText to a list of words to be ignored when spell checking.

CheckSpelling_IsWordIgnored     ( string pText ) ,byte,proc
if MyWord.CheckSpelling_IsWordIgnored ('CapeSoft') = true
...

  • Used by the templates when spell checking
  • Returns true (1) if the word pass as pText is in the list of words to be ignored

CloseDoc     ( ) ,byte,proc
MyWord.CloseDoc()
TempByte = MyWord.CloseDoc()

  • Closes the currently open document
  • Returns true (1) if no problems were experienced

CloseFooter     ( ) ,byte,proc
MyWord.CloseFooter()
  • Used after you have called the OpenFooter method to make the footer section of the document "inactive", so that you can continue working on the document.
  • Returns true (1) if no problems were experienced

CloseHeader     ( ) ,byte,proc
MyWord.CloseHeader()
  • Used after you have called the OpenHeader method to make the header section of the document "inactive", so that you can continue working on the document.
  • Returns true (1) if no problems were experienced

Copy     ( ) ,byte,proc
MyWord.Copy()
TempByte = MyWord.Copy()

  • Copies the current selection to the clipboard
  • Returns true (1) if no problems were experienced

CountCharacters     (  ) ,long
TempLong = MyWord.CountCharacters ()
  • Returns the number of characters in the document, or a negative value if an error occurred.

CountOpenDocs     (  ) ,long
TempLong = MyWord.CountOpenDocs()
  • Returns the number of currently open documents
  • Returns a value less than 0 if an error occurred

CountTables     (  ) ,long
TempLong = MyWord.CountTables ()
  • Returns the number of tables in the current document, or a negative value if an error occurred.


Cut     ( ) ,byte,proc
MyWord.Cut()
TempByte = MyWord.Cut()

  • Cuts the current selection to the clipboard
  • Returns true (1) if no problems were experienced

FindText  (string pText), long

Searches the document for the passed strings and returns 1 and selects the string if found, or returns zero and does not change current selection if the string does not exist in the document. This can be called multiple times to find each instance of the string in the document (for example to make each instance of the string bold - see the example below).

Parameters

string pText: The string to search for in the document

Return Values

Returns 1 if successful and selects the string that was found, or if the string cannot be found it returns zero.

Examples

! Find all instances of the word 'Hello' and make them bold.
loop while
myWord.FindText('Hello')
    myWord.Bold(oiw:BoldOn)
end

ErrorTrap     ( string pErrorString, string pFunctionName )

MyWord1.ErrorTrap PROCEDURE (string pErrorString, string pFunctionName) 
  code
    parent.ErrorTrap(pErrorString, pFunctionName)
   
if pErrorString = 'Init Failed'
       
Message('Could not initialise Word! Please ensure that MS Word is installed.')
    end

 

  • This method is called when an error occurs.  Office Inside provides embed points for this method (before parent call, and after parent call) where you can put code to deal with any errors Office Inside experiences (see the example code above - note the grey text indicates code generated by the Office Inside template, the black text is what you would add).
  • By default any errors that Office Inside encounters will be dealt with as follows:
    • First, this ErrorTrap method is called, where you can act on the error message as shown in the example code above.
    • Second, Outlook might display a message of its own.  You can suppress all messages by ticking the Suppress Error Messages check box in the procedure extension template.
  • Note 1 : Even if you suppress error messages the ErrorTrap method will still be called.
  • Note 2 : The Suppress Error Messages checkbox simply generates a line of code that sets the SuppressErrorMessages property to true.  You can set this property manually if you prefer.

GetFontColor     ( ) ,long
TempLong = MyWord.GetFontColor()
  • Returns the color (value) of the currently selected text.
  • If the color value (long) matches any of the standard Clarion color equates, the method will return that equate (e.g. COLOR:Green), or it will simply return a long (color).


GetFontName     ( ) ,string
 TempString = MyWord.GetFontName()
  • Returns the font name (font) for the currently selected text.

GetFontNames     (  ) ,byte,proc
MyWord.GetFontNames ()
  • Returns true (1) if no problems were encountered.
  • Populates a queue (property) called self.FontNamesQ with a list of all available fonts.

GetFontSize     ( ) ,long
TempLong = MyWord.GetFontSize()
  • Returns the current font size
  • Returns a negative value if an error occurred

GetInfo     ( byte pOption ) ,string,proc
TempString = MyWord.GetInfo (oiw:GetUserName)
  • This is a wrapper method which can be used to get various information, and read various properties, depending on the parameters which you pass.
  • The pOption parameter can be one of the GetInfo/Update Equates.
  • The string which is returned contains the information pertaining to the parameter you requested information about.

GetNameOfDictionary     ( ) ,string
TempString = MyWord.GetNameOfDictionary()
  • Returns the name (and full path) of the dictionary currently being used (to check spelling)

GetSelectionEnd     ( ) ,long
TempLong = MyWord.GetSelectionEnd()
  • Returns the position of the last selected character within the document.
  • Returns a negative value if an error occurred.

GetSelectionStart     ( ) ,long
TempLong = MyWord.GetSelectionStart()
  • Returns the position of the first selected character within the document.
  • Returns a negative value if an error occurred.

GetText     ( byte pScope=oiw:GetText_All ) ,byte,proc
if MyWord1.GetText (oiw:GetText_CurrentSelection) = true
  stop(MyWord1.TempCString)
end
  • This method updates an Office Inside property called self.TempCString (*cstring) with the text found in the currently loaded document.  Use the pScope parameter to tell this method which text you want, passing one of the following values / equates:
    • oiw:GetText_CurrentSelection  - returns currently selected text
    • oiw:GetText_All  - returns all text in document
  • This method returns a byte indicating whether the method worked successfully (in which case "1" is returned), or whether an error occurred (in which case "0" is returned).
  • NOTE:  The self.TempCString property should be treated as read-only...

GotoEndOfDoc ( ), byte, proc

Moves the cursor to the end of the current document.

Return Values

Returns true (1) if no problems were experienced.

Examples

MyWord.GotoEndOfDoc()
if not MyWord.GotoEndOfDoc()
    Message('
Could not go to the end of the document, an error occured.')
end

See Also

GotoItem

GotoItem (long  pItem, <long pDirection>, <long  pName>, <long pCount>), long, proc

Moves the cursor to a location within the document, based on the parameters which you pass. Can be used to navigate to a position in the document based on a line, paragraph, bookmark, character position etc. The pItem parameter is used to specify which item to go to, and the pDirection parameter specifies which one of those items to go to (the first, last etc.). You can set the pDirection to oiw:GotoAbsolute and then use the pCount parameter to specify the number of the item to go to (for example the 4th line in a document).

Note: If the pItem parameter is oiw:GoToBookmark, oiw:GoToComment, oiw:GoToField, or oiw:GoToObject, this parameter specifies a name and the pName field must be passed to specify which item is referred to.

Parameters

long pItem: The item to go to. Can be one of the GoTo equates:

  • oiw:GoToBookmark - goes to the bookmark specified by the pName.
  • oiw:GoToSection - goes to the section specified by the pDirection and pCount parameters.
  • oiw:GoToPage - goes to the page specified by the pDirection and pCount parameters.
  • oiw:GoToTable - goes to the table specified by the pDirection and pCount parameters.
  • oiw:GoToLine - goes to the line specified by the pDirection and pCount parameters.
  • oiw:GoToFootnote - goes to the footnote specified by the pDirection and pCount parameters.
  • oiw:GoToEndnote- goes to the endnote specified by the pDirection and pCount parameters.
  • oiw:GoToComment - goes to the comment specified by the pName.
  • oiw:GoToField - goes to the field specified by the pName parameter.
  • oiw:GoToGraphic  - goes to the comment specified by the pDirection and pCount parameters.
  • oiw:GoToObject  - goes to the comment specified by the pName parameters.
  • oiw:GoToEquation  - goes to the comment specified by the pDirection and pCount parameters.
  • oiw:GoToHeading  - goes to the comment specified by the pDirection and pCount parameters.
  • oiw:GoToSpellingError  - goes to the comment specified by the pDirection and pCount parameters.
  • oiw:GoToGrammaticalError  - goes to the comment specified by the pDirection and pCount parameters.
  • oiw:GoToPercent  - goes to the comment specified by the pDirection and pCount parameters.
  • oiw:GoToProofreadingError - goes to the comment specified by the pDirection and pCount parameters.

long pDirection: Specifies which items to go to, can be used in combination with the pCount parameter. For example if pDirection is set to oiw:GoToPrevious, then the count parameter can specify how many previous to go to (setting it to 4 will go to 4 items previous to the current one). May be one of the following values:

  • oiw:GoToAbsolute - goes to a specific item, for example the 2nd table or 12th line in a document. Use the pCount parameter to specify which instance of the item to go to.
  • oiw:GoToFirst - goes to the first occurrence of the item specified by the pItem parameter (table, line, paragraph etc.)
  • oiw:GoToLast - goes to the last occurrence of the item specified by the pItem parameter (table, line, paragraph etc.)
  • oiw:GoToNext - goes to the next occurrence of the item specified by the pItem parameter (table, line, paragraph etc.). Can be use in conjunction with the pCount parameter to move that number of the specified items.
  • oiw:GoToPrevious - goes to the previous occurrence of the item specified by the pItem parameter (table, line, paragraph etc.). Can be use in conjunction with the pCount parameter to move that number of the specified items.
  • oiw:GoToRelative - moves the number of pItems indicated by the pCount parameter relative to the current item. For example can be used to go four lines down from the current one.

Returns Values

Returns true (1) if no problems were experienced and false (0) if an error occurs. In the case of an error the ErrorTrap method will be called with a string indicating what error occurred.

Examples

! Go to the last line in the document
MyWord.GotoItem(oiw:GoToLine, oiw:GoToLast)
! Go to a named bookmark
MyWord1.GotoItem(oiw:GoToBookmark, , '
FirstName')
! Go to the first footnote in the document
MyWord1.GotoItem(oiw:GoToFootnote, oiw:GotoFirst)
! Move down 4 lines
MyWord1.GotoItem(oiw:GoToLine, oiw:GotoRelative, , 4)
! move back two pages
MyWord1.GotoItem(oiw:GoToPage, oiw:GotoPrevious, , 2)
! Move the insertion point just before the fifth endnote reference in the document
MyWord1.GotoItem(oiw:GoToEndNote, oiw:GotToAbsolute, , 5)
! Move the selection to the first cell in the next table
MyWord1.GotoItem(oiw:GoToTable, oiw:GotoNext)
! Select the Date field (assumes that there is a field in the document with the name Date)
MyWord1.GotoItem(oiw:GoToField, , '
Date')

HideToolbar     ( long pToolbar ) ,byte,proc
MyWord.HideToolbar (oiw:ToolbarStandard)
TempByte = MyWord.HideToolbar (oiw:ToolbarStandard)
  • Sets a MS Word toolbar to be hidden.  For a list of valid equates which can be used, click here.
  • Returns true (1) if no problems were experienced.

InchesToPoints     ( string pInches ) ,string
loc:Points = MyWord.InchesToPoints(1.6875)
MyWord.Update(oiw:PageLeftMargin, MyWord.InchesToPoints(1.6875))

Init     ( byte StartVisible=1, byte EnableEvents=1 ) ,byte,proc
MyWord.Init()
TempByte = MyWord.Init()

  • This method does several things, which can be summed us as "Getting everything ready so you can call the other methods in this class".  This involves...   ( To do )
  • Returns true (1) if no problems were experienced.
  • Note:  The first time you initialize an oiWord object (after starting your app), it might take a second or two to start an instance (process) of MS Word, which it then uses.  Any subsequent objects that you initialize will first check to see whether they can use that existing instance of MS Word before they start their own instance.  This speeds up the method significantly, especially for doing things like using the Spell Checker.  This is all taken care of for you by the dll, and is mentioned here purely for those who are interested.  When your app closes, any instances (processes) of MS Word that the dll started will be closed for you automatically.   ( Must redo this... )
  • Note: You can also set whether Word is visible after you have called the Init method by using the Update method, passing oiw:ApplicationVisible.

InsertBreak     ( long pBreakType=oiw:PageBreak ) ,byte,proc
MyWord.InsertBreak ()
MyWord.InsertBreak (oiw:PageBreak)
MyWord.InsertBreak (oiw:TextWrappingBreak)

  • Inserts a break into the current document.  See the Break-Types Equates which you can pass as the
  • Returns true (1) if no problems were experienced.

InsertPicture     ( string FileName ) ,byte,proc
MyWord.InsertPicture ('c:\mypic.bmp')
TempByte = MyWord.InsertPicture ('c:\mypic.bmp')

  • Inserts a picture (image) into the current document, at the current selection.
  • Before calling this method, you can set the ImageProperties property to control how the image will be inserted.  For example:
      MyWord.ImageProperties.ScaleWidth = 80 ! 80 percent of original width
      MyWord.ImageProperties.ScaleHeight = 80 ! 80 percent of original height
      MyWord.InsertPicture ('c:\mypic.bmp')
  • Returns true (1) if no problems were experienced.

InsertTable     ( long NumColumns, long NumRows ) ,long,proc
MyWord.InsertTable (6, 3)
TempByte = MyWord.InsertTable (6, 3)

  • Inserts a table into the current document, at the current selection / position.
  • Returns 0 if a problem occurred, or the number of tables ( the table you just inserted will be the last table in the document / i.e. the highest number / i.e. the table number that is returned ) if the table was inserted successfully.
  • TIP :  If you have for example three tables in a document, and add a fourth table, this method would return the value "4".  If you then deleted a table (say the second table that you inserted), then insert another table, this method would again return "4".  What was table 3 before you deleted table 2 would now become table 2, the "old" table 4 would become table 3, and the new table will be table 4.  In other words, tables don't keep their table numbers if you start deleting tables.

InsertText     ( string pText, byte pOption=0 ) ,byte,proc    or    ( *cstring pText, byte pOption=0 ) ,byte,proc
MyWord.InsertText ('Hello World')
TempByte = MyWord.InsertText ('Hello World')

  • Inserts text into the current document.
  • pOption can be one of the following values:
    • 0  - default value.  text is inserted at or over the current selection
    • 1  - text is inserted before the current selection
    • 2  - text is inserted after the current selection
  • Returns true (1) if no problems were experienced.

InsertTextbox     ( string pText ) ,byte,proc

Inserts a textbox into the current document. A Word textbox can be used to create complex layouts, and position blocks of text anywhere on the document.

Before calling this method, you need to set up several properties, as shown in the example code above.  This lets you set up exactly how the TextBox will be drawn when you finally call the InsertTextbox method.

The self.Textbox.TextOrientation property can be set to any equate listed here.
The self.Textbox.ZOrder property can be set to any equate listed here.

  • NOTE:  The self.Textbox.BorderColor and self.Textbox.TextColor properties can either be standard clarion color equates (as shown above), or RGB color values, e.g. 0D7D7D7H.
  • NOTE:  You must either set the self.Textbox.XPos property or the self.Textbox.BoxAlignment property.  There is no point in setting both.
  • NOTE:  Once this method has completed drawing the textbox, focus returns to your document, at the line immediately above where the textbox was drawn.  If there is no line in your document above the textbox, focus will stay on / in the textbox.  Call the NextLine method before calling this method to ensure that focus returns to your "document" once InsertTextbox completes, e.g.
    MyWord.NextLine ( )
    ! set up properties, as shown above
    MyWord.InsertTextbox ('Hello World')

 

Return Values

Returns true (1) if no problems were experienced.

Example:

MyWord.Textbox.BoxAlignment = oiw:ShapeCenter
MyWord.Textbox.YPos = 153
MyWord.Textbox.Width = 200
MyWord.Textbox.Height = 50
MyWord.Textbox.ShowBorders = true
MyWord.Textbox.BorderColor = color:yellow
MyWord.Textbox.BorderWidth = '5'
MyWord.Textbox.TextFont = 'Arial'
MyWord.Textbox.TextSize = 20
MyWord.Textbox.TextColor = color:red
MyWord.Textbox.TextOrientation = oiw:TextOrientationHorizontal
MyWord.Textbox.TextAlignment = oiw:AlignParagraphRight
MyWord.Textbox.ZOrder = oiw:SendBehindText
MyWord.Textbox.MoveWithText = false
! once the properties are set we can now call the method...
MyWord.InsertTextbox ('Hello world!')

Italic     ( byte pOption ) ,byte,proc
MyWord.Italic (oiw:ItalicToggle)
TempByte = MyWord.Italic (oiw:ItalicToggle)

  • Makes the selected text italicized / not italicized.
  • Returns true (1) if no problems were experienced.
  • pOption can be one of the following equates:
    • oiw:ItalicOn
    • oiw:ItalicOff
    • oiw:ItalicToggle

Kill     ( byte UnloadCOM=1 ) ,byte,proc
MyWord.Kill()
TempByte = MyWord.Kill()

  • Closes any currently open documents (using the CloseDoc method)
  • Closes MS Word
  • Kills the oiWord object and handles any cleaning up.
  • Returns true (1) if no problems were experienced.

LinesToPoints     ( string pLines ) ,string
loc:Points = MyWord.LinesToPoints(5)
MyWord.Update(oiw:PageLeftMargin, MyWord.LinesToPoints(5))

MailMergeGetRecord     ( byte pOption=0 ) ,byte,proc
MyWord.MailMergeGetRecord ()
  •  ( Please do not use this method yet... )

MailMergeRun     ( ) ,byte,proc
MyWord.MailMergeRun()
TempByte = MyWord.MailMergeRun()

  • Starts a Mail Merge process.
  • This method calls the MailMergeUpdate method before the actual merge begins.
  • Returns true (1) is no problems were reported.

MailMergeSetDataSource     ( string DataSourceName, string ConnectionString, string SQLStatement ) ,byte,proc
MyWord.MailMergeSetDataSource ( (longpath() & '\Addresses.mdb'), 'TABLE Office_Address_List', 'SELECT * FROM [Office_Address_List]' )
  • When you create and save a Mail Merge document, it stores the path to its Data Source.  If this path changes (e.g. when you ship) the Word document will no longer be able to open the Data Source.  This method enables you to set the Data Source path at run-time, which enables you to get around this problem (as shown in the example above).
  • A valid Mail Merge document must already be open before calling this method.
  • Returns true (1) is no problems were reported.

MillimetersToPoints     ( string pMillimeters ) ,string
loc:Points = MyWord.MillimetersToPoints(10)
MyWord.Update(oiw:PageLeftMargin, MyWord.MillimetersToPoints(1.10))

MoveDown     ( byte pUnit=oiw:UnitLine, long pCount=1, byte pExtend=oiw:Move ) ,byte,proc
MyWord.MoveDown() ! move down one line
  • Has the same effect on your document as if you pressed the "down arrow" key on the keyboard.
  • The pExtend parameter can be either oiw:Move or oiw:Extend
  • Returns true (1) is no problems were reported.

MoveLeft     ( byte pUnit=oiw:UnitCharacter, long pCount=1, byte pExtend=oiw:Move ) ,byte,proc
MyWord.MoveLeft() ! move left one character
  • Has the same effect on your document as if you pressed the "left arrow" key on the keyboard.
  • The pExtend parameter can be either oiw:Move or oiw:Extend
  • Returns true (1) is no problems were reported.

MoveRight     ( byte pUnit=oiw:UnitCharacter, long pCount=1, byte pExtend=oiw:Move ) ,byte,proc
MyWord.MoveRight() ! move right one character
  • Has the same effect on your document as if you pressed the "right arrow" key on the keyboard.
  • The pExtend parameter can be either oiw:Move or oiw:Extend
  • Returns true (1) is no problems were reported.

MoveUp     ( byte pUnit=oiw:UnitLine, long pCount=1, byte pExtend=oiw:Move ) ,byte,proc
MyWord.MoveUp() ! move up one line
  • Has the same effect on your document as if you pressed the "up arrow" key on the keyboard.
  • The pExtend parameter can be either oiw:Move or oiw:Extend
  • Returns true (1) is no problems were reported.

NewDoc     ( <string TemplateName> ) ,byte,proc
MyWord.NewDoc()
TempByte = MyWord.NewDoc()
MyWord.NewDoc ('MyTemplate.dot') ! assumes system default template directory
MyWord.NewDoc (longpath() & '/templates/MyTemplate.dot')

  • Creates a new document
  • Returns true (1) if no problems were experienced.
  • If you don't pass a TemplateName parameter, MS Word will use the "normal.dot" template, which is standard behavior.  If you do pass a template name, the full path to the ".dot" file must be passed, unless the ".dot" file is in the default template directory.

NextLine     (  ) ,byte,proc
MyWord.NextLine()
TempByte = MyWord.NextLine()

  • Moves to the next line within the document.  Same as pressing the "Enter" button from within MS Word.
  • Returns true (1) if no problems were experienced.

OpenDoc     ( string pFileName, byte pReadOnly=false, byte pAddToRecentFiles=false, <string pPassword> ) ,byte,proc
MyWord.OpenDoc('c:\test.doc')
TempByte = MyWord.OpenDoc('c:\test.doc')

  • Opens an existing document
  • Returns true (1) if no problems were experienced.
  •  ( Seems to be a problem under Win XP / Office XP if the datasource is not in the original folder... )

OpenFooter     ( ) ,byte,proc
MyWord.OpenFooter()
  • Makes the footer section of the currently open document "active", so that you can work on / in it.
  • Returns true (1) if no problems were experienced.

OpenHeader     ( ) ,byte,proc
MyWord.OpenHeader()
  • Makes the header section of the currently open document "active", so that you can work on / in it.
  • Returns true (1) if no problems were experienced.

Paste     ( ) ,byte,proc
MyWord.Paste()
TempByte = MyWord.Paste()

  • Pastes from the clipboard to the current selection / cursor position within a Word document.
  • Returns true (1) if no problems were experienced.

PicasToPoints     ( string pPicas ) ,string
loc:Points = MyWord.PicasToPoints(8)
MyWord.Update(oiw:PageLeftMargin, MyWord.PicasToPoints(8))

PixelsToPoints     ( string pPixels, byte pVertical=false ) ,string
loc:Points = MyWord.PixelsToPoints(15)
MyWord.Update(oiw:PageLeftMargin, MyWord.PixelsToPoints(15))

PointsToCentimeters     ( string pPoints ) ,string
loc:Points = MyWord.PointsToCentimeters(6)
MyWord.Update(oiw:PageLeftMargin, MyWord.PointsToCentimeters(6))

PointsToInches     ( string pPoints ) ,string
loc:Points = MyWord.PointsToInches(14)
MyWord.Update(oiw:PageLeftMargin, MyWord.PointsToInches(14))

PointsToLines     ( string pPoints ) ,string
loc:Points = MyWord.PointsToLines(8)
MyWord.Update(oiw:PageLeftMargin, MyWord.PointsToLines(8))

PointsToMillimeters     ( string pPoints ) ,string
loc:Points = MyWord.PointsToMillimeters(14)
MyWord.Update(oiw:PageLeftMargin, MyWord.PointsToMillimeters(14))

PointsToPicas     ( string pPoints ) ,string
loc:Points = MyWord.PointsToPicas(12)
MyWord.Update(oiw:PageLeftMargin, MyWord.PointsToPicas(12))

PointsToPixels     ( string pPoints, pVertical=false ) ,string
loc:Points = MyWord.PointsToPixels(13)
MyWord.Update(oiw:PageLeftMargin, MyWord.PointsToPixels(13))

PrintDialog     ( ) ,byte,proc
MyWord.PrintDialog()
TempByte = MyWord.PrintDialog()

  • ( Not yet implemented... )
  • Returns true (1) if no problems were experienced.

PrintMe     (<string pPages>, byte pRange=oiw:PrintAllDocument, long pCopies=1, byte pPageType=oiw:PrintAllPages, byte pBackground=false, <string pPrinterName>) ,byte,proc

Prints the currently loaded document. This method has been replaced by the PrintOut(), which expands the supported options and is currently in Beta (see below).

Parameters

  • The pPages parameter holds the page numbers / ranges to be printed.  If you do not pass a value in this parameter, a value of "print everything" is implied, but not passed.  (See "notes" below).  Valid examples for this parameter include:
    • '5, 6, 12'
    • '3, 5, 8-15'
  • The pRange parameter can be one of the following values:
    • oiw:PrintAllDocument (default)
    • oiw:PrintSelection
    • oiw:PrintCurrentPage
    • oiw:PrintFromTo  (not supported, use pPages instead)
    • oiw:PrintRangeOfPages (see notes below)
  • The pCopies parameter is not supported by this method, use PrintOut() instead.
  • The pPageType parameter can be one of the following values:
    • oiw:PrintAllPages  (default)
    • oiw:PrintOddPagesOnly
    • oiw:PrintEvenPagesOnly
  • The pBackground parameter determines whether this method returns before or after the document has actually been sent to the printer.  This is very useful.  Passing this parameter as "true" (1) will make the method return faster (as it does not wait for confirmation that the document has been sent to the printer), but you need to consider the implications of this.  One implication is that calling MyWord.Kill might cause MS Word to show the "Word is currently printing.  Quitting Word will cancel all pending jobs" warning.  Passing this parameter as "false" (0) guarantees that the document has been sent to the printer before the PrintMe method returns, solving the problem (at the cost of a slight delay when you call the method).
  • The pPrinterName parameter can be used to specify a printer other than the default printer, for example:
    MyWord.PrintMe ('1',,,,,'PDF-XChange 3.0')

Notes

In order for the pPages parameter to work, pRange needs to be oiw:PrintRangeOfPages.  If you pass a value in pPages, and also pass anything other than oiw:PrintRangeOfPages in pRange, we will simply ignore what you pass in pRange.  We do this so that the following code will work, even though pRange is going to default to oiw:PrintAllDocument, which wouldn't ordinarily work:
MyWord.PrintMe ( '3,4,7-8' )

If you're wanting to print a document to a printer other than the system default printer, the "safest" way to do this seems to be it is done in the "Two Printers" example.  Notes can be found in that example.

Examples

TempByte = MyWord.PrintMe ()
MyWord.PrintMe ('2,4,5-8') ! oiw:PrintRangeOfPages implied (see "Notes")
MyWord.PrintMe ('2,4', oiw:PrintRangeOfPages)
MyWord.PrintMe ( ,oiw:PrintCurrentPage)
MyWord.PrintMe ( ,oiw:PrintSelection)
MyWord.PrintMe ( ,,,oiw:PrintOddPagesOnly)
MyWord.PrintMe ( ,,2)
MyWord.PrintMe ('1',,,,,'Lexmark 3200')

PrintOut (*oiwPrintProperties printSettings, string printerName)

The PrintOut method expand on the simple PrintMe() method and exposes all the properties supports by Word. The oiwPrintProperties group type is provided to allow the setting to be easily set and passed.

Parameters

*oiwPrintProperties printSettings

A oiwPrintProperties group that contains the settings to be used for printing. See below for a description of the group type and fields. This is a TYPE'd group and can be used to create your own PrintSettings groups as follows:

myPrintSettings   group(oiwPrintProperties)
                  end

string printName

The name of the printer to use for printing.

Return Values

Returns 1 for success and zero if the COM interface encountered an error.

Data Types

 

oiwPrintProperties Type Fields
 
Name Type Description
background long Set to True to have the code to execute continue while Microsoft Word prints the document.
pAppend long Set to True to append the specified document to the file name specified by the OutputFileName argument. False to overwrite the contents of OutputFileName.
pRange long The page range. Can be any oiw:PrintOutRange constant:
oiw:PrintAllDocument equate(0)
oiw:PrintSelection   equate(1)
oiw:PrintCurrentPage equate(2)
oiw:PrintFromTo      equate(3)
oiw:PrintRangeOfPages equate(4)
outputFileName cstring(256) If PrintToFile is True, this argument specifies the path and file name of the output file.
pFrom long The starting page number when Range is set to oiw:PrintFromTo.
pTo long The ending page number when Range is set to oiw:PrintFromTo.
pItem long The item to be printed. Can be any oiw:PrintOutItem constant:
oiw:PrintDocumentContent equate(0)
oiw:PrintProperties      equate(1)
oiw:PrintMarkup          equate(2)
oiw:PrintComments        equate(2)
oiw:PrintStyles          equate(3)
oiw:PrintAutoTextEntries equate(4)
oiw:PrintKeyAssignments  equate(5)
oiw:PrintEnvelope        equate(6)
oiw:PrintDocumentWithMarkup equate(7)
copies long The number of copies to be printed.
pages cstring(1024) The page numbers and page ranges to be printed, separated by commas. For example, "2, 6-10" prints page 2 and pages 6 through 10.
pageType   The type of pages to be printed. Can be any oiw:PrintOutPages constant:
oiw:PrintAllPages      equate(0)
oiw:PrintOddPagesOnly  equate(1)
oiw:PrintEvenPagesOnly equate(2)
printToFile   True to send printer instructions to a file. Make sure to specify a file name with OutputFileName.
collate   When printing multiple copies of a document, True to print all pages of the document before printing the next copy.
FileName   The path and file name of the document to be printed. If this argument is omitted, Word prints the active document. (not tested)
activePrinterMacGX   Not supported on the Windows platform.
manualDuplexPrint   True to print a two-sided document on a printer without a duplex printing kit. If this argument is True, the PrintBackground and PrintReverse properties are ignored. This argument may not be available to you, depending on the language support that you’ve selected or installed.
printZoomColumn   The number of pages you want Word to fit horizontally on one page. Can be 1, 2, 3, or 4. Use with the PrintZoomRow argument to print multiple pages on a single sheet.
printZoomRow   The number of pages you want Word to fit vertically on one page. Can be 1, 2, or 4. Use with the PrintZoomColumn argument to print multiple pages on a single sheet.
printZoomPaperWidth   The width to which you want Word to scale printed pages, in twips (20 twips = 1 point; 72 points = 1 inch).
printZoomPaperHeight   The height to which you want Word to scale printed pages, in twips (20 twips = 1 point; 72 points = 1 inch).
 
     

 

PrintPreview     ( ) ,byte    or    ( byte pOption ) ,byte,proc
TempByte = MyWord.PrintPreview ()
  ( TempByte will be 1 if on, 0 if not )


MyWord.PrintPreview (1)  ! turn print preview on
MyWord.PrintPreview (0)  ! turn print preview off
MyWord.PrintPreview (2)  ! toggle print preview


TempByte = MyWord.PrintPreview (1) ! turn print preview on
! TempByte will return 1 if passed, 0 if an error occurred

  • Print Previews the current document, or establishes whether the current document is being previewed.

Protect  (long protectionType, string pPassword), long

Enables do