편집

다음을 통해 공유


Application.CopyFile method (Outlook)

Copies a file from a specified location into a Microsoft Outlook store.

Syntax

expression. CopyFile( _FilePath_ , _DestFolderPath_ )

expression A variable that represents an Application object.

Parameters

Name Required/Optional Data type Description
FilePath Required String The path name of the object you want to copy.
DestFolderPath Required String The location you want to copy the file to.

Return value

An Object value that represents the copied file.

Example

The following Visual Basic for Applications (VBA) example creates a Microsoft Excel worksheet called 'MyExcelDoc.xlsx' and then copies it from the user's hard drive to the user's Inbox.

Sub CopyFileSample() 
 
 Dim strPath As String 
 
 Dim ExcelApp As Object 
 
 Dim ExcelSheet As Object 
 
 Dim doc As Object 
 
 
 
 
 
 Set ExcelApp = CreateObject("Excel.Application") 
 
 strPath = ExcelApp.DefaultFilePath & "\MyExcelDoc.xlsx" 
 
 Set ExcelSheet = ExcelApp.Workbooks.Add 
 
 ExcelSheet.ActiveSheet.cells(1, 1).Value = 10 
 
 ExcelSheet.SaveAs strPath 
 
 ExcelApp.Quit 
 
 Set ExcelApp = Nothing 
 
 Set doc = Application.CopyFile(strPath, "Inbox") 
 
End Sub

See also

Application Object

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.