Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Access to open MS Project

Status
Not open for further replies.

tetsuo2030

Programmer
Sep 9, 2011
3
0
0
US
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):
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?


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top