Use the ActiveDocument object to refer to the document currently displayed in the editor. To access an open document that is not active, use the Application.DocumentCache object.
CanRedo: WordBool (read-only)
Boolean. Returns True if changes can be re-done.
function Main() {
var sMessage;
sMessage = "CanRedo : ";
with (Application) {
If(ActiveDocument.CanRedo)
sMessage = sMessage + "Yes";
Else
sMessage = sMessage + "No";
MessageBox(sMessage, VersionText, 0);
}
}
CanUndo: WordBool (read-only)
Boolean. Returns True if changes can be undone.
function Main() {
var sMessage;
sMessage = "CanUndo : ";
with (Application) {
If(ActiveDocument.CanUndo)
sMessage = sMessage + "Yes";
Else
sMessage = sMessage + "No";
MessageBox(sMessage, VersionText, 0);
}
}
CaretPosX: integer (read-only)
function Main(){
with (Application){
if (ActiveDocument.CaretPosX > 1){
ActiveDocument.CursorLineStart(false);
}
}
}
CaretPosY: integer (read-only)
function Main(){
with (Application){
if (ActiveDocument.CaretPosY > 1){
ActiveDocument.CursorDocStart(false);
}
}
}
Filename: OleString (read-only)
File name of the active document.
function Main() {
var sMessage;
sMessage = "Your file name is: ";
with (Application) {
sMessage = sMessage + ActiveDocument.Filename;
MessageBox(sMessage, VersionText, 0);
}
}
LineCount: integer (read-only
Number of lines in the active document.
function Main() {
var sMessage;
sMessage = "Your file line count is: ";
with (Application) {
sMessage = sMessage + ActiveDocument.LineCount;
MessageBox(sMessage, VersionText, 0);
}
}
Lines(Index: integer) OleString
Gets and sets the text of the line at the passed index. Iterating through a document using the Lines property might be slow, especially for large documents. For best results, only use Lines to evaluate single lines of text. If you must use Lines to update many lines, you can increase performance by wrapping the update in a BeginUpdate..EndUpdate block.
function Main(){
with (Application){
ActiveDocument.Lines(0) = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">';
}
}
Modified: WordBool (read-only)
Boolean. Returns True if the document changed since it was last saved.
function Main() {
var sMessage;
sMessage = "Modified : ";
with (Application) {
If(ActiveDocument.Modified)
sMessage = sMessage + "Yes";
Else
sMessage = sMessage + "No";
MessageBox(sMessage, VersionText, 0);
}
}
ReadOnly: WordBool (read-only)
Boolean. Returns True if the active document is read-only.
function Main(){
with (Application){
if (ActiveDocument.ReadOnly){
MessageBox('Current document is Read-Only', 'Information', 0);
}
}
}
SelStart: integer
Gets and sets the start of the current selection.
function Main(){
with (Application){
with (ActiveDocument){
// Select entire document
SelStart = 0;
CursorDocEnd(true);
}
}
}
SelLength: integer
Gets and sets the length of the current selection.
function Main() {
var sMessage;
sMessage = "The length of the selected text of your document is ";
with (Application) {
sMessage = sMessage + ActiveDocument.SelLength;
MessageBox(sMessage, VersionText, 0);
}
}
SelText: OleString
Gets and sets the text in the current selection.
function Main() {
var sMessage;
sMessage = "The length of the selected text of your document is ";
with (Application) {
sMessage = sMessage + ActiveDocument.SelText;
MessageBox(sMessage, VersionText, 0);
}
}
TabIndex
Gets and sets the tab index of the document tab.
function Main(){
with (Application){
if (ActiveDocument.TabIndex != 0){
DocumentIndex = 0;
}
}
}
Text: OleString
Gets and sets the complete document text.
BeginUpdate();
Turns off screen updating for the active document. This is useful if your script needs to make several changes to the active document at once-turning off screen updating during the procedure might significantly speed up the process. To turn on updating again, use EndUpdate.
Use BeginUpdate...EndUpdate with caution. If you fail to call EndUpdate after a call to BeginUpdate, or if the script crashes before EndUpdate is called, the user cannot view any changes made in the editor.
Clear();
Clears all text from the active document.
Close(wbPromptToSave: WordBool): WordBool;
Boolean. Closes the active document. If wbPromptToSave is True, the user is prompted to save any changes. Returns True if the document was closed (that is, the user didn't cancel saving changes).
Cursor_ (wbSelect: WordBool);
Boolean. Positions the cursor. If wbSelect is True, then the current selection is extended to the new cursor position.
The following values are allowed:
CursorLeft, CursorRight, CursorWordLeft, CursorWordRight, CursorDown, CursorUp, CursorPageDown, CursorPageUp, CursorDocStart, CursorDocEnd, CursorLineStart, CursorLine End.
function Main(){
with (Application){
// Select the entire line
ActiveDocument.CursorLineStart(false);
ActiveDocument.CursorLineEnd(true);
}
}
EndUpdate();
Turns on screen updating for the active document.
function Main(){
var iTags = 0;
with (Application){
ActiveDocument.BeginUpdate();
ActiveDocument.CursorDocStart(false);
try{
while (ActiveDocument.GotoNextStartTag(false)){
iTags++;
}
}
finally{
ActiveDocument.EndUpdate();
}
MessageBox('Total tags: ' + iTags, 'Tag Count', 0);
}
}
GetCaretPos(var x, y: integer);
Returns the caret pos (x=column, y=line).
GetCurrentChar(): OleVariant;
Returns the current character.
GetNextChar(): OleVariant;
Returns the next character. If you use this function, along with GetPreviousChar, in long loops, the code can run slowly.
GetPreviousChar(): OleVariant;
Returns the previous character.
GetTagAtCursor(wbSelect: WordBool): WideString;
Boolean. Returns the tag in which the cursor is currently located in the editor. If a tag cannot be identified, the method returns an empty string.
If wbSelect is True, the tag is highlighted in the document.
// Displays a message box with the current tag
function Main() {
with (Application) {
MessageBox(ActiveDocument.GetTagAtCursor(false), 'Current Tag At Cursor', 0);
}
}
GotoNextEndTag(wbSelect: WordBool): WordBool;
Boolean. Moves the next end tag, and selects it if wbSelect is True. Returns False if no tag found.
GotoNextStartTag(wbSelect: WordBool): WordBool;
Boolean. Moves the next starting tag and selects it if wbSelect is True. Returns False if no tag is found.
GotoPreviousEndTag(wbSelect: WordBool): WordBool;
Boolean. Moves the previous end tag and selects it if wbSelect is True. Returns False if no tag is found.
function Main(){
with (Application){
ActiveDocument.GotoPreviousEndTag(false);
}
}
GotoPreviousStartTag(wbSelect: WordBool): WordBool;
Boolean. Moves the previous starting tag and selects it if wbSelect is True. Returns False if no tag is found.
function Main(){
with (Application){
ActiveDocument.GotoPreviousStartTag(true);
}
}
Indent();
Indents the current selection.
InsertTag(sStartTag, sEndTag: OleVariant; wbOverwriteSelection: WordBool);
Boolean. Inserts the passed tag pair at the current cursor position, overwriting the selection if wbOverwriteSelection is True. The cursor is positioned between the start and end tags after this operation. If wbOverwriteSelection is False, the tags surround the current selection.
function Main(){
with (Application){
ActiveDocument.CursorDocEnd(false);
ActiveDocument.InsertTag('<a href="http://www.macromedia.com">', '</a>', true);
}
}
InsertText(InsertStr: OleVariant; wbOverwriteSelection: WordBool);
Boolean. Inserts the passed string at the current cursor position. If wbOverwriteSelection is True, this function overwrites the selection.
LastSavedDate();
Returns the datetime value for the last save of the active document file.
function Main(){
with (Application){
SetStatusText('Last save: ' + ActiveDocument.LastSavedDate());
}
}
Print(wbNoPrompt: WordBool);
Boolean. Prints the active document. If wbNoPrompt is False, prompts the user for print settings.
Redo();
Performs a single redo operation.
Reload(wbPromptToSave: WordBool);
Boolean. Reloads the active document. If wbPromptToSave is True, prompts the user to save changes.
ReplaceAll(strSearch, strReplace: OleVariant; bMatchCase: WordBool): Integer;
Boolean. Replaces all occurrences of strSearch with strReplace, matching case if bMatchCase is True. Returns the number of replacements made.
Save: WordBool();
Boolean. Saves changes to the active document. Returns True if successful.
SaveAs(wsFileName: widestring): WordBool;
Boolean. Saves changes to the active document to the file specified in the wsFileName parameter.Returns True if successful.
If wsFileName is empty, the standard Save As dialog box displays. This function overwrites existing files, so use it with caution.
function Main(){
var sFile = '';
// Insert a link and create the file in one step
with (Application){
sFile = InputBox('Add File Link', 'Enter a filename to create and link to:', sFile);
if (sFile == ''){
return;
}
ActiveDocument.InsertTag('<a href="' + sFile + '">', '</a>', false);
NewDocument(true);
ActiveDocument.SaveAs(CurrentFolder + '\\' + sFile);
}
}
SelectAll();
Selects all the text in the active document.
SelectCurrentLine();
SelectLine(Index: Integer);
SetCaretPos(x, y: Integer);
TextPosToEditorPos(var nPos:OleVariant):WordBool;
Boolean. Converts an index in a text string in a VBScript script to the corresponding editor position. Takes into account tabs and newlines, which count as two characters in the text but only as one in the editor. Returns the nPos parameter as an OleVariant, but its actual type is integer.
This method is only supported in VBScript.
Undo();
Performs a single undo operation.
Unindent();
Removes the indent in the current selection.
LiveDocs comments are not longer enabled for ColdFusion 5.0. Please use one of the following resources instead.
ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting
Version 5.0