Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

CopyFile Method

Office 2003

Copies a file from a specified location into a Microsoft Outlook store and returns an Object representing the copied document.

expression.CopyFile(FilePath, DestFolderPath)

expression    Required. An expression that returns an Application object.

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.

Example

The following Visual Basic for Applications (VBA) example creates a Microsoft Excel worksheet called 'MyExcelDoc.xls' 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 olApp As New Outlook.Application
    Dim doc As Object
    
    
    strPath = "C:\MyExcelDoc.xls"
    Set ExcelApp = CreateObject("Excel.Application")
    Set ExcelSheet = ExcelApp.Workbooks.Add
    ExcelSheet.ActiveSheet.cells(1, 1).Value = 10
    ExcelSheet.SaveAs strPath
    ExcelApp.Quit
    Set ExcelApp = Nothing
    
    Set doc = olApp.CopyFile(strPath, "Inbox")
    
End Sub


		


Applies to | Application Object



Show:
© 2015 Microsoft