none
Vanishing File RRS feed

  • Question

  • I have a macro (see code below) that saves a temporary copy of a file which is processed and then deleted. At the end of the macro, the original file is re-opened. The macro works well except for files that have been saved as mpp’s from Project Server 2007.

     

    For those files, the code to re-open the file does not work. No error condition is raised by the code—the file simply does not appear. Worse, when I try to manually open the file through Project (File/Open/<select the file>), I get an error message saying “Project cannot open the file…Check the file name and format”.  The same problem occurs when I leave Project open and try to access the file by double clicking it in Windows Explorer. But, when I close Project and re-open it, I’m able to access the file.

     

    Does anyone know what accounts for this behaviour and how to avoid it?

     

    Code Excerpt:

    TempOrigFileName = ActiveProject.FullName

    <validate file type as mpp and path for next step>

         TempProjFileName = Left(TempOrigFileName, Len(TempOrigFileName) - 4) & ".bak"

         FileSaveAs TempProjFileName, Format:=pjMPP

    <process temp file>

    FileClose pjDoNotSave

    Kill TempProjFileName

    FileOpen Name:=TempOrigFileName

    Sunday, September 12, 2010 7:48 PM

Answers

  • Hi Rob,

    I tried to reproduce your problem using the code sample you posted here, but I could not reproduce the problem. It seems to work fine on my machine. Can you try to run the macro I have used as a test, to see if it also works for you (the macro simply saved the .bak file and reopens the original).

    Sub test()
        Dim TempOrigFileName As String
        Dim TempProjFileName As String
       
        TempOrigFileName = ActiveProject.FullName
        TempProjFileName = Left(TempOrigFileName, Len(TempOrigFileName) - 4) & ".bak"
        FileSaveAs TempProjFileName, Format:=pjMPP
        FileClose pjDoNotSave
        Kill TempProjFileName
        FileOpen Name:=TempOrigFileName
    End Sub

    I see two possible causes. Somewhere in your process temp file code, a problem is introduced (modification of TempOrigFile, ...). Or it could be because you are still using SP1. Have you tried Using the lastest service pack (SP2) and CU installed on Microsoft Project?

    I hope this helps,
    Hans


    My EPM blog: Projectopolis
    Monday, September 13, 2010 6:39 AM
    Moderator

All replies

  • Hi,

    TempOrigFileName  holds a name such as "My project name.mpp"

    To re-open the file, the name should be "<>\My project name.mpp"

    Does that work? I assume you have all service packs and CUs installed?


    Rod Gill

    The one and only Project VBA Book Rod Gill Project Management
    Sunday, September 12, 2010 8:53 PM
    Moderator
  • No, Rod, that did not work. I get an error message saying that project needs to be connected to the server. But, the macro is running in Project 2007 (stand alone version) against an mpp file that was saved from Project Pro 2007 and Project Server 2007. The version of stand-alone project is MS Project 2007 with SP1 (12.0.6213.1000).
    Sunday, September 12, 2010 9:24 PM
  • Hi Rob,

    I tried to reproduce your problem using the code sample you posted here, but I could not reproduce the problem. It seems to work fine on my machine. Can you try to run the macro I have used as a test, to see if it also works for you (the macro simply saved the .bak file and reopens the original).

    Sub test()
        Dim TempOrigFileName As String
        Dim TempProjFileName As String
       
        TempOrigFileName = ActiveProject.FullName
        TempProjFileName = Left(TempOrigFileName, Len(TempOrigFileName) - 4) & ".bak"
        FileSaveAs TempProjFileName, Format:=pjMPP
        FileClose pjDoNotSave
        Kill TempProjFileName
        FileOpen Name:=TempOrigFileName
    End Sub

    I see two possible causes. Somewhere in your process temp file code, a problem is introduced (modification of TempOrigFile, ...). Or it could be because you are still using SP1. Have you tried Using the lastest service pack (SP2) and CU installed on Microsoft Project?

    I hope this helps,
    Hans


    My EPM blog: Projectopolis
    Monday, September 13, 2010 6:39 AM
    Moderator
  • Thanks, Hans. When I run the macro you defined, I get exactly the same problem as with my macro.  I will apply SP2 and CU to see if that resolves the problem.
    Monday, September 13, 2010 1:17 PM