Permission Denied

P

Pierre Scerri

I am using a form in Outlook 2003 that has 3 option buttons.
Button 1 changes the view to Calendar. Buttons 2 and 3 switch to 1 of 2
folders in 'Notes'. Each of the 2 folders in 'Notes' points to a different
website.
Button 2 is the default. If i switch using Button 3 and back to Button 2
all is well. If i switch using button 1 (calendar view) and back to button 2,
i get a permission denied error. The code that is activated when i click
buton 2 is:
Private Sub OptCWP_Click()
If MyFolder Is Nothing Then Set MyFolder =
Application.GetNamespace("MAPI").GetDefaultFolder(olFolderNotes).Folders("Crew Web Portal")
With Application.ActiveExplorer
Set .CurrentFolder = MyFolder
Do While .HTMLDocument.readyState <> "complete": DoEvents: Loop
If InStr(1, .HTMLDocument.Location, "CWPLogin") Then...

The code stops at this line with the permission denied error. Clicking past
the error and pressing F5, execution continues normally.

I suspect that the webpage hasn't fully loaded even if i've put a loop to
wait for it. Is this the correct way to wait for the page to load?

Thank you

PS Can i access the HTNL contents of a folder that points to a webpage using
Getexplorer without actually displaying the folder in a separate window?
 
K

Ken Slovak - [MVP - Outlook]

If you set the WebViewURL property of the MAPIFolder object for one of those
Notes subfolders you can just read that property from the MAPIFolder object
without involving an Explorer at all.

I'm unclear however what you want to happen. Do you want those Notes folders
with Web pages to actually be displayed and show the Web site? If so then
you do need the Explorer and you need to make the folder the CurrentFolder.
If you want to show the Web site in a separate window you can use automation
to open an IE window and navigate to the Web site that way.

Does the correct Web site show up when you select one of those Notes folders
in the user interface, without code? No errors that way?

Is there any difference in coding between buttons 2 and 3? What happens if
you go from button 1 to button 3? Any errors then?
 
P

Pierre Scerri

Thank you for your reply.

I was initially using IE for this. That stopped when i found out i could
use outlook itself as a browser.

The web page involved is a login page. I can programmatically input
username and password and click the login button on the page without
problems.

I then need to make sure that the login has been successful by checking the
..HTMLdocument.location to see whether it contains the word 'CWPLogin' in its
address.

If it does then login failed and i have to try again otherwise login is ok
and i can continue.

Looking at the Webviewurl does not help.

The correct website shows up - no problem there.

I do not really need to show the webpage at all come to think of it. Can i
still manipulate the data in that webpage if it is not visible? When i say
manipulate i mean that the webpage contains time data that i need to retreive
and use to set appointments (this is part is already working well)

The problem is that i need a delay loop to wait for the webpage to load
completly before doing anyrhing else, and i keep getting the permission
denied error.

I have since tried making the folder as a subfolder of 'Calendar'. Same
error.
I also dispensed with the idea of a subfolder and set the Webviewurl in
Calendar properties. Same error.

Can't think of a way out. Yet
 
K

Ken Slovak - [MVP - Outlook]

In cases like that I use IE, don't show the IE window, and avoid using
Outlook as a Web browser entirely.
 
P

Pierre Scerri

Thanks for the feedback. However i feel that using IE does not solve the
problem. It avoids it. Furthermore if i use the same code on a Vista
machine, the code fails as Vista seems to launch IE in 2 pieces.

Using Outlook as the browser would probably avoid that.

Also all the code is working except that the delay loop that waits for the
page to load is not doing what i would like it to do. As i said before,
resuming execution after the 'Permission Denied' error, the code works.

Anyway. Once again for your input
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top