Location Property

Microsoft Office Visual Basic

Returns the location of the script anchor in the specified HTML document. Read-only MsoScriptLocation.

MsoScriptLocation can be one of these MsoScriptLocation constants.
msoScriptLocationInBody
msoScriptLocationInHead

Remarks

Script tags in an HTML document can appear anywhere between the <HTML> tags in the document. In Microsoft Word, Excel, or PowerPoint, only the script anchors located between the <BODY> tags are visible. Additional HTML script that appears before or after the <BODY> tags is stored in but isn’t visible to the user.

The Scripts collection contains all of the script anchors that appear in the document, whether inside or outside of the main body of the document. Using the Location argument of the Add method, you can insert script anchors within the <HEAD> and <BODY> tags in the HTML document. You can also use the Location property to determine where a particular script anchor is stored within the document.

Example

This example checks the Location property of the first script in worksheet one in the active workbook and displays the location in a message box.

If ActiveWorkbook.Worksheets(1).Scripts(1).Location = 1 Then
    MsgBox "The script in located in the header."
End If
If ActiveWorkbook.Worksheets(1).Scripts(1).Location = 2 Then
    MsgBox "The script in located in the body of the worksheet."
End If