Vanishing File
-
2010年9月12日 19:48
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
すべての返信
-
2010年9月12日 20:53モデレータ
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 -
2010年9月12日 21:24No, 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).
-
2010年9月13日 6:39モデレータ
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 SubI 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- 回答の候補に設定 Christophe FiessingerMicrosoft Employee, Owner 2010年9月13日 16:35
- 回答としてマーク Christophe FiessingerMicrosoft Employee, Owner 2010年10月5日 3:28
-
2010年9月13日 13:17Thanks, 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.