Hyperlink.CreateNewDocument method (Access)

You can use the CreateNewDocument method to create a new document associated with a specified hyperlink.


expression. CreateNewDocument( _FileName_, _EditNow_, _Overwrite_ )

expression A variable that represents a Hyperlink object.


Name Required/Optional Data type Description
FileName Required String The name and path of the document. The type of document format you want used can be determine by the extension used with the filename. to output the data. You can create HTML (.htm), Microsoft Active Server Pages (.asp), Microsoft Excel (.xls), Microsoft IIS (.htx, .idc), MS-DOS Text (.txt), or Rich Text Format (*.rtf). Modules can be output only to MS-DOS text format. Microsoft Internet Information Server and Microsoft Active Server formats are available only for tables, queries, and forms.
EditNow Required Boolean True opens the document in design view and False stores the new document in the specified database directory. The default is True.
Overwrite Required Boolean True overwrites an existing document if the filename argument identifies an existing document and False requires that the filename argument specifies a new filename. The default is False.

Return value



The CreateNewDocument method provides a way to programmatically create a document associated with a hyperlink within a control.


The following example utilizes a hyperlink control's Click event. This event creates a new file named "Report.txt" when the user clicks the hyperlink control named "GenerateReport" on a form. The new file opened for editing. If a file named "Report.txt" already exists on drive C, it is replaced with this new file.

Private Sub GenerateReport_Click() 
 ActiveControl.Hyperlink.CreateNewDocument _ 
 "C:\Report.txt", EditNow:=True, Overwrite:=True 
End Sub

See also

Hyperlink Object