Open Method

Microsoft FrontPage Visual Basic

Opens a file in a Web site.

expression.Open

expression    Required. An expression that returns a WebFile object.

ShowOpen method as it applies to the Webs object.

Opens a Web site. Returns a WebEx object.

expression.Open(szWebUrl, UserName, Password, WebOpenFlags)

expression    Required. An expression that returns a Webs object.

szWebUrl   Required String. The base URL of the Web site, such as "C:\My Web Sites". This can be any absolute URL, such as "http://web server   " or "file://file system   " for disk-based Web sites.

UserName   Optional String. The logon name of the user.

Password   Optional String. A designated string of characters to validate access to the specified Web site.

WebOpenFlags   Optional FpWebOpenFlags.

Note  Avoid using hard-coded passwords in your applications. If a password is required in a procedure, request the password from the user, store it in a variable, and then use the variable in your code. For recommended best practices on how to do this, see Security Notes for Microsoft Office Solution Developers.

FpWebOpenFlags can be one of these FpWebOpenFlags constants.
fpOpenInWindow default
fpOpenNoWindow

Example

The following example opens the Rogue Cellars Web site and the Oktoberfest Sale file, and performs the following tasks:

  • Adds text to the file by creating a property to hold the text.
  • Accesses the Page object model using the ActiveDocument property and the insertAdjacentText method.
  • Adds text to the page by substituting mySaleProp for the text parameter in the insertAdjacentText method.
  • Closes Microsoft FrontPage.

Note  To run this example, you must have a Web site called "C:\My Documents\My Web Sites\Rogue Cellars", or you may substitute an alternative Web site URL and file name.

Private Sub AddSaleText()

    Dim objWeb As Web
    Dim objFile As WebFile
    Dim strSaleProp As String
    Dim strSaleText As String

    strSaleText = "Vintage Wines for Oktoberfest Sale!!!"
    Set objWeb = Webs.Open("C:\My Documents\My Web Sites\Rogue Cellars")
    Set objFile = ActiveWeb.RootFolder.Files("Sale.htm")

    objFile.Properties.Add "SaleText", mySaleText
    strSaleProp = objFile.Properties("SaleText")
    objFile.Open
    ActiveDocument.body.insertAdjacentText "BeforeEnd", strSaleProp
    WebWindows.Close

End Sub