CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 2011
    Posts
    1

    Copying a file with attributes

    I'm using FileCopy in Excel VBA to copy a file from one folder to another. When I do that, the file loses all the attributes I've added on the summary tab. How can I move or copy a file from one folder to another and retain the attributes?

  2. #2
    Join Date
    Jun 2009
    Posts
    113

    Re: Copying a file with attributes

    Can you post your code segment where you're trying to copy the file? I ran a quick test in both VBScript and VBA and it seems to work fine (I had set the Title and Subject of the source spreadsheet):

    Set objFSO=CreateObject("Scripting.FileSystemObject")
    objFSO.CopyFile "C:\Scripts\Book1.xls","C:\Book1.xls",TRUE

    The following VBScript shows the values:

    Set objExcel = CreateObject("Excel.Application")
    objExcel.Visible = False
    Set objWorkbook = objExcel.Workbooks.Open("C:\Book1.xls")
    On Error Resume Next
    For Each strProperty in objWorkbook.BuiltInDocumentProperties
    Wscript.Echo strProperty.Name & " – " & strProperty.Value
    Next
    objExcel.Quit

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured