<< Click to Display Table of Contents >> Application (object) |
Access path: Application
1 Description
Application is the "root object" for all other objects in PlanMaker. It is the central control object that is used to carry out the whole communication between your Basic script and PlanMaker.
2 Access to the object
There is exactly one instance of the Application object. It is available during the whole time that PlanMaker is running and accessed directly through the object variable returned by the CreateObject function:
Set pm = CreateObject("PlanMaker.Application")
MsgBox pm.Application.Name
As Application is the default property of PlanMaker, it can generally be omitted:
Set pm = CreateObject("PlanMaker.Application")
MsgBox pm.Name ' has the same meaning as pm.Application.Name
3 Properties, objects, collections and methods
Properties:
▪FullName R/O
▪Name R/O (default property)
▪Path R/O
▪Build R/O
▪Bits R/O
▪Visible
▪Caption R/O
▪Left
▪Top
▪Width
▪Height
▪WindowState
▪Calculation
▪CalculateBeforeSave
▪DisplayCommentIndicator
▪EditDirectlyInCell
▪MoveAfterReturn
▪MoveAfterReturnDirection
▪PromptForSummaryInfo
▪WarningOnError
Objects:
▪Options → Options
▪UserProperties → UserProperties
▪CommandBars → CommandBars
▪AutoCorrect → AutoCorrect
▪ActiveWorkbook → Workbook
▪ActiveSheet → Sheet
▪ActiveWindow → Window
▪ActiveCell → Range
▪Selection → Range
▪Range → Range
▪Cells → Range
▪Application → Application
Collections:
▪Workbooks → Workbooks
▪Windows → Windows
▪RecentFiles → RecentFiles
▪FontNames → FontNames
▪Columns → Columns
▪Rows → Rows
Methods:
▪CentimetersToPoints
▪MillimetersToPoints
▪InchesToPoints
▪PicasToPoints
▪LinesToPoints
▪Activate
▪Calculate
▪Quit
FullName (property, R/O)
Data type: String
Returns the name and path of the program (e.g. "C:\Program Files\SoftMaker Office\PlanMaker.exe").
Name (property, R/O)
Data type: String
Returns the name of the program, i.e. "PlanMaker".
Path (property, R/O)
Data type: String
Returns the path of the program, for example "C:\Program Files\SoftMaker Office\".
Build (property, R/O)
Data type: String
Returns the build number of the program as a string, for example "1000".
Bits (property, R/O)
Data type: String
Returns a string corresponding to the bit version of the program: "32" for the 32-bit version, "64" for the 64-bit version of PlanMaker.
Visible (property)
Data type: Boolean
Gets or sets the visibility of the program window:
pm.Application.Visible = True ' PlanMaker becomes visible
pm.Application.Visible = False ' PlanMaker becomes invisible
Important: By default, Visible is set to False – thus, PlanMaker is initially invisible until you explicitly make it visible.
Caption (property, R/O)
Data type: String
Returns a string with the contents of the title bar of the program window (e.g. "PlanMaker - MyTable.pmdx").
Left (property)
Data type: Long
Gets or sets the horizontal position (= left edge) of the program window on the screen, measured in screen pixels.
Top (property)
Data type: Long
Gets or sets the vertical position (= top edge) of the program window on the screen, measured in screen pixels.
Width (property)
Data type: Long
Gets or sets the width of the program window on the screen, measured in screen pixels.
Height (property)
Data type: Long
Gets or sets the height of the program window on the screen, measured in screen pixels.
WindowState (property)
Data type: Long (SmoWindowState)
Gets or sets the current state of the program window. The possible values are:
smoWindowStateNormal = 1 ' normal
smoWindowStateMinimize = 2 ' minimized
smoWindowStateMaximize = 3 ' maximized
Calculation (property)
Data type: Long (PmCalculation)
Gets or sets the setting whether documents should be recalculated automatically or manually. The possible values are:
pmCalculationAutomatic = 0 ' Update calculations automatically
pmCalculationManual = 1 ' Update calculations manually
Notes:
▪PlanMaker allows you to apply this setting per document, whereas it is a global setting in Excel. This property is supported by PlanMaker only for compatibility reasons. It is recommended to use the identically named property Calculation in the Workbook object instead, as it allows you to change this setting for each document individually.
▪If you retrieve this property while multiple documents are open where this setting has different values, the value smoUndefined will be returned.
CalculateBeforeSave (property)
Data type: Boolean
Gets or sets the setting whether documents should be recalculated when it is saved.
Notes:
▪This property has an effect only if calculations are set to be updated manually. If the Calculation property (see there) is set to pmCalculationAutomatic, all calculations will always be kept up-to-date anyway.
▪PlanMaker allows you to apply this setting per document, whereas it is a global setting in Excel. This property is supported by PlanMaker only for compatibility reasons. It is recommended to use the identically named property CalculateBeforeSave in the Workbook object instead, as it allows you to change this setting for each document individually.
▪If you retrieve this property while multiple documents are open where this setting has different values, the value smoUndefined will be returned.
DisplayCommentIndicator (property)
Data type: Long (PmCommentDisplayMode)
Gets or sets the mode in which comments are shown. The possible values are:
pmNoIndicator = 0 ' Show neither comments nor yellow triangle
pmCommentIndicatorOnly = 1 ' Show only a yellow triangle
pmCommentOnly = 2 ' Show comments, but no yellow triangle
pmCommentAndIndicator = 3 ' Show both comments and triangle
Notes:
▪PlanMaker allows you to apply this setting per document, whereas it is a global setting in Excel. This property is supported by PlanMaker only for compatibility reasons. It is recommended to use the identically named property DisplayCommentIndicator in the Workbook object instead, as it allows you to change this setting for each document individually.
▪If you retrieve this property while multiple documents are open where this setting has different values, the value smoUndefined will be returned.
EditDirectlyInCell (property)
Data type: Boolean
Gets or sets the setting whether cells can be edited directly in the spreadsheet or only in the Edit bar displayed above the spreadsheet.
MoveAfterReturn (property)
Data type: Boolean
Gets or sets the setting whether the cell frame should advance to another cell when the user presses the Enter key.
If this property is set to True, the MoveAfterReturnDirection property (see there) will be automatically set to pmDown. However, you can later choose a different direction.
MoveAfterReturnDirection (property)
Data type: Long (PmDirection)
Gets or sets the direction into which the cell frame should move when the user presses the Enter key. The possible values are:
pmDown = 0 ' down
pmUp = 1 ' up
pmToRight = 2 ' right
pmToLeft = 3 ' left
PromptForSummaryInfo (property)
Data type: Boolean
Gets or sets the setting "Ask for document info when saving", which can be found in PlanMaker on the Files tab in the dialog box of the ribbon command File | Options.
WarningOnError (property)
Data type: Boolean
Gets or sets the setting "Warning if a formula contains errors", which can be found in PlanMaker on the Edit tab in the dialog box of the ribbon command File | Options.
Options (pointer to object)
Data type: Object
Returns the Options object that you can use to access global program settings of PlanMaker.
UserProperties (pointer to object)
Data type: Object
Returns the UserProperties object that you can use to access the name and address of the user.
CommandBars (pointer to object)
Data type: Object
Returns the CommandBars object that you can use to access the toolbars of PlanMaker.
Note: Toolbars work only in classic mode. They do not work with ribbons.
AutoCorrect (pointer to object)
Data type: Object
Returns the AutoCorrect object that you can use to access the automatic correction settings of PlanMaker.
ActiveWorkbook (pointer to object)
Data type: Object
Returns the currently active Workbook object that you can use to access the active document.
ActiveSheet (pointer to object)
Data type: Object
Returns the currently active Sheet object that you can use to access the active worksheet of the active document.
ActiveSheet is an abbreviation for the ActiveWorkbook.ActiveSheet. The following both calls have the same meaning:
MsgBox pm.Application.ActiveWorkbook.ActiveSheet
MsgBox pm.Application.ActiveSheet
ActiveWindow (pointer to object)
Data type: Object
Returns the currently active Window object that you can use to access the active document window.
ActiveCell (pointer to object)
Data type: Object
Returns a Range object that represents the active cell in the current document window. You can use this object to read and edit the formatting and content of the cell.
ActiveCell is an abbreviation for ActiveWindow.ActiveCell. The following both calls have the same meaning:
pm.Application.ActiveWindow.ActiveCell.Font.Size = 14
pm.Application.ActiveCell.Font.Size = 14
Please note that ActiveCell always returns just one single cell, even if a range of cells is selected in the worksheet. After all, selected ranges have exactly one active cell as well. You can see that when you select cells and then press the Enter key: a cell frame appears within to selection to indicate the active cell.
Selection (pointer to object)
Data type: Object
Returns a Range object that represents the selected cells in the active worksheet of the current document window.
Selection is an abbreviation for ActiveWorkbook.ActiveSheet.Selection. The following both calls have the same meaning:
pm.Application.ActiveWorkbook.ActiveSheet.Selection.Font.Size = 14
pm.Application.Selection.Font.Size = 14
Range (pointer to object)
Data type: Object
Based on the parameters passed, creates a Range object that refers to the active worksheet of the current document and returns it. You can use this object to access the cells in a range and, for example, get or set their values.
Syntax 1:
obj = Range(Cell1)
Syntax 2:
obj = Range(Cell1, Cell2)
Parameters:
Cell1 (type: String) specifies either according to syntax 1 a cell range (then Cell2 must be omitted) or according to syntax 2 the upper left corner of a range (then parameter Cell2 specifies the lower right corner of the range). |
Cell2 (optional; type: String) should be used only if Cell1 refers to an individual cell. |
Examples for syntax 1: |
Range("A1:B20") ' Cells A1 to B20
Range("A1") ' Only cell A1
Range("A:A") ' Column A as a whole
Range("3:3") ' Row 3 as a whole
Range("Summer") ' Named range "Summer"
Example for syntax 2: |
Range("A1", "B20") ' Cells A1 to B20
Range is an abbreviation for ActiveWorkbook.ActiveSheet.Range. The following both calls have the same meaning:
pm.Application.ActiveWorkbook.ActiveSheet.Range("A1:B5").Value = 42
pm.Application.Range("A1:B5").Value = 42
Cells (pointer to object)
Data type: Object
Returns a Range object that contains all cells of the current worksheet. This is useful for two applications:
▪To apply an operation (e.g., formatting) to every cell of the worksheet:
' Make the whole active worksheet red
pm.Cells.Shading.ForegroundPatternColor = smoColorRed
▪To address individual cells with loop variables instead of specifying the address as a string (such as "B5" for the second column in the fifth row). To do this, use the Item property of the Range object that is addressed through the Cells pointer:
' Fill the first 5 * 10 cells of the active worksheet with 42
Dim row, col as Integer
For row = 1 To 5
For col = 1 to 10
pm.Cells.Item(row, col).Value = 42
Next col
Next row
Cells is an abbreviation for ActiveSheet.Cells. The following both calls have the same meaning:
pm.Application.ActiveSheet.Cells(1, 1).Font.Size = 14
pm.Application.Cells(1, 1).Font.Size = 14
Application (pointer to object)
Returns the Application object, i.e. the pointer to itself. This object pointer is basically superfluous and only provided for the sake of completeness.
Workbooks (pointer to collection)
Data type: Object
Returns the Workbooks collection, a collection of all currently opened documents.
Windows (pointer to collection)
Data type: Object
Returns the Windows collection, a collection of all currently open document windows.
RecentFiles (pointer to collection)
Data type: Object
Returns the RecentFiles collection, a collection of the recently opened documents (as displayed at the bottom of PlanMaker's File menu).
FontNames (pointer to collection)
Data type: Object
Returns the FontNames collection, a collection of all installed fonts.
Columns (pointer to collection)
Data type: Object
Returns the Columns collection, a collection of all columns in the active worksheet.
Columns is an abbreviation for ActiveWorkbook.ActiveSheet.Columns. The following both calls have the same meaning:
MsgBox pm.Application.ActiveWorkbook.ActiveSheet.Columns.Count
MsgBox pm.Application.Columns.Count
Rows (pointer to collection)
Data type: Object
Returns the Rows collection, a collection of all rows in the active worksheet.
Rows is an abbreviation for ActiveWorkbook.ActiveSheet.Rows. The following both calls have the same meaning:
MsgBox pm.Application.ActiveWorkbook.ActiveSheet.Rows.Count
MsgBox pm.Application.Rows.Count
CentimetersToPoints (method)
Converts the given value from centimeters (cm) to points (pt). This function is useful if you make calculations in centimeters, but a PlanMaker function accepts only points as its measurement unit.
Syntax:
CentimetersToPoints(Centimeters)
Parameters:
Centimeters (type: Single) specifies the value to be converted. |
Return type:
Single |
Example:
' Set the top margin of the active worksheet to 3cm
pm.ActiveSheet.PageSetup.TopMargin = pm.Application.CentimetersToPoints(3)
MillimetersToPoints (method)
Converts the given value from millimeters (mm) to points (pt). This function is useful if you make calculations in millimeters, but a PlanMaker function accepts only points as its measurement unit.
Syntax:
MillimetersToPoints(Millimeters)
Parameters:
Millimeters (type: Single) specifies the value to be converted. |
Return type:
Single |
Example:
' Set the top margin of the active worksheet to 30mm
pm.ActiveSheet.PageSetup.TopMargin = pm.Application.MillimetersToPoints(30)
InchesToPoints (method)
Converts the given value from inches (in) to points (pt). This function is useful if you make calculations in inches, but a PlanMaker function accepts only points as its measurement unit.
Syntax:
InchesToPoints(Inches)
Parameters:
Inches (type: Single) specifies the value to be converted. |
Return type:
Single |
Example:
' Set the bottom margin of the active worksheet to 1 inch
pm.ActiveSheet.PageSetup.BottomMargin = pm.Application.InchesToPoints(1)
PicasToPoints (method)
Converts the given value from picas to points (pt). This function is useful if you make calculations in picas, but a PlanMaker function accepts only points as its measurement unit.
Syntax:
PicasToPoints(Picas)
Parameters:
Picas (type: Single) specifies the value to be converted. |
Return type:
Single |
Example:
' Set the bottom margin of the active worksheet to 6 picas
pm.ActiveSheet.PageSetup.BottomMargin = pm.Application.PicasToPoints(6)
LinesToPoints (method)
Identical to the PicasToPoints method (see there).
Syntax:
LinesToPoints(Lines)
Parameters:
Lines (type: Single) specifies the value to be converted. |
Return type:
Single |
Example:
' Set the bottom margin of the active worksheet to 6 picas
pm.ActiveSheet.PageSetup.BottomMargin = pm.Application.LinesToPoints(6)
Activate (method)
Brings the program window to the foreground and sets the focus to it.
Syntax:
Activate
Parameters:
none |
Return type:
none |
Example:
' Bring PlanMaker to the foreground
pm.Application.Activate
Note: This command is only successful if Application.Visible = True.
Calculate (method)
Recalculates all currently open documents (similar to the ribbon command Formula | Update group | Update data | Update calculations in PlanMaker, except that the ribbon command only recalculates the active workbook).
Syntax:
Calculate
Parameters:
none |
Return type:
none |
Example:
' Recalculate all open workbooks (documents)
pm.Application.Calculate
Quit (method)
Ends the program.
Syntax:
Quit
Parameters:
none |
Return type:
none |
Example:
' End PlanMaker
pm.Application.Quit
If there are any unsaved documents open, the user will be asked if they should be saved. If you want to avoid this question, you need to either close all opened documents in your program or set the property Saved for the document to True (see Workbook).