WebFile Object
SharePoint Designer Developer Reference |
Represents a file in a Web site.
Remarks
The WebFile object is a member of the WebFiles collection. The WebFiles collection represents all of the files in a specified WebFolder object. Within the WebFiles collection, individual WebFile objects are indexed beginning with zero. The WebFile object is similar to a file in a directory-based hierarchy. You have the ability to create multiple Web objects on a Web server. Any WebFolder object can represent a Web site, but every WebFolder object does not necessarily represent a Web site.
Use WebFiles(index), where index is the ordinal number of a Web page, to return a single WebFile object. The following example returns the file name of the first Web page in the WebFiles collection.
Visual Basic for Applications |
---|
|
Use the File object to return information about a file on a Web site. The following example returns the Name, Title, and Url properties of each File object on the active Web site.
Note
To run this procedure, you must have a least one Web site open.
Visual Basic for Applications |
---|
|
Use the IsOpen property to determine whether a file is currently open in Page view. The following example returns the IsOpen property for a specified File object. Notice that the Edit method is used to open the file in this example. For more information on using these methods, see the Edit method.
Note
You must have a Web site open to run this procedure.
Visual Basic for Applications |
---|
|
Use the Checkin, Checkout, and UndoCheckout methods to manage file resources through source control on a Web site. The following statement checks out the first file in the active Web site.
Note
You must have a source control project set up for this statement to work.
Visual Basic for Applications |
---|
|
Similar to file management features in Microsoft Visual SourceSafe, Office SharePoint Designer also provides an UndoCheckout method that you can use to return a file to its original state. The following statement returns the file to its original state.
Visual Basic for Applications |
---|
|
You can use the CheckedoutBy property before attempting to check out a file to determine whether the file is currently checked out and by whom. The following statement returns the logon alias of the person who checked out a file or is null if the file isn't currently checked out.
Visual Basic for Applications |
---|
|
Use the Properties property to return information about a Web site, such as the type of Web server (vti_webservertype) or whether the Web site has a search bot (vti_hassearchbot). The Properties property returns a collection of key-value pairs used to maintain the meta information. The following statement returns True for the variable mySearchBot if the Web site has a search bot.
Visual Basic for Applications |
---|
|
Use the MetaTags property to return information about the meta tags contained in the HTML coding of a file. The MetaTags property returns a collection of meta tags for a File object, such as the generator of the file. The following example returns the file name and meta tags for each file in a Web site.
Note
To run this procedure, you must have a least one Web site open.
Visual Basic for Applications |
---|
|
Use the SharedBorders property to return the shared borders on the current Web page or to set new shared borders. The following statement returns the top shared border of the first file in the Files collection of the active Web site.
Visual Basic for Applications |
---|
|
You can also set shared borders on a Web page, as shown in the following statement.
Visual Basic for Applications |
---|
|
Use the ThemeProperties property to return information about whether the theme uses vivid colors or active graphics. The following example returns the properties of an applied theme and adds vivid colors to the current theme properties if vivid colors haven't been applied to the specified object.
Visual Basic for Applications |
---|
|
Using File methods
Use the Copy, Delete, Edit, Move, or Open methods to manage your Web pages. A subtle distinction exists between the Edit and Open methods. With the Edit method, you can open and modify a Office SharePoint Designer–compatible file into a PageWindow object. With the Open method, you can open both Office SharePoint Designer–compatible files and any other type of file such as image or text files into the editor that is associated with the file. When you use the Open method to open a file type that is not compatible with Office SharePoint Designer, Office SharePoint Designer does not return a file object. The following example opens a file, deletes a file, and moves a file.
Note
To run this example, you must have a Web site named "C:\My Documents\My Webs Sites\Coho Winery".
Visual Basic for Applications |
---|
|
See Also