tetsuo2030
Programmer
Greetings all.
I developed a form that takes data from an Access table and pushes it to MS Project. I recently came across an issue that I thought would be a simple fix: Password Protected .mpp files.
From Access, I use late-binding to create an instance of MS Project, then I open the user's file via FileOpen. This was all well and good until one guy decides to password protect his file; now the FileOpen method halts and a message box from MS Project pops up asking for the password--right in the middle of my procedure. I don't want this, so I just wanted to write a simple test: "[Is the .mpp file password protected?] If so, Msgbox "Hey, unprotect this first" Exit Sub".
I looked around on google, and the best I found was a similar test for an Excel application where the guy created a test by opening the workbook and intentionally sending it a blank password on the open args; on error '1004', MsgBox "Protected..." Exit Sub
So, I tried it with MS Project; I open and I intentionally send it a bogus password. Now the message box doesn't show up, which is good, but it doesn't error-out, which is bad. The FileOpen simply isn't happening, and none of my subsequent commands to Project work nor error either.
old code that generates password prompt (if password protected):
new code doesn't prompt, but doesn't error:
Any ideas?
I developed a form that takes data from an Access table and pushes it to MS Project. I recently came across an issue that I thought would be a simple fix: Password Protected .mpp files.
From Access, I use late-binding to create an instance of MS Project, then I open the user's file via FileOpen. This was all well and good until one guy decides to password protect his file; now the FileOpen method halts and a message box from MS Project pops up asking for the password--right in the middle of my procedure. I don't want this, so I just wanted to write a simple test: "[Is the .mpp file password protected?] If so, Msgbox "Hey, unprotect this first" Exit Sub".
I looked around on google, and the best I found was a similar test for an Excel application where the guy created a test by opening the workbook and intentionally sending it a blank password on the open args; on error '1004', MsgBox "Protected..." Exit Sub
So, I tried it with MS Project; I open and I intentionally send it a bogus password. Now the message box doesn't show up, which is good, but it doesn't error-out, which is bad. The FileOpen simply isn't happening, and none of my subsequent commands to Project work nor error either.
old code that generates password prompt (if password protected):
Code:
Dim appProj As Object
Dim strPATH as String
strPATH = "C:..."
Set appProj = CreateObject("MSProject.Application")
appProj.FileOpen strPath, ReadOnly:=False, IgnoreReadOnlyRecommended:=True
new code doesn't prompt, but doesn't error:
Code:
Dim appProj As Object
Dim strPATH as String
strPATH = "C:..."
Set appProj = CreateObject("MSProject.Application")
appProj.FileOpen strPath, ReadOnly:=False, Password:="abc", WriteResPassword:="abc", IgnoreReadOnlyRecommended:=True
Any ideas?