Reading Pane in vba

A

_-Andy-_

Hellow,
I want to check if the ReadingPane is On in vba.
How can i do this?
i found a method ShowReadingPane but i can't find an example on how to
use it.
It's supposed to be a part of a Tableview?
Anyone has some suggestions?
Thanks in advance
 
A

_-Andy-_

It seems that i found it ;)
If Explorers.Item(1).IsPaneVisible(olPreview) = True Then

That's at least one possibility.
I use this for a locking mechanisme for files in public folders in
outlook.
But it locked also in preview mode :s
no it doesn't
but i can't lock it anymore now :s
It's in the event ReadAttachment
Is there an Event DoubleClick??
 
A

_-Andy-_

I need something else
How can i turn the Preview (Reading) Pane off and on?
Again i need to know how to call the ShowReadingPane method :s
Anyone please?
 
S

Sue Mosher [MVP-Outlook]

The generic method is Explorer.ShowPane, e.g.

application.ActiveExplorer.ShowPane olPreview, False

Or, for a table view, set the ShowReadingPane property to False.
 
A

_-Andy-_

Sorry about the double post i forgot i answered already and it didn't
show.
i have some code sample :

Private Sub objDocumentItem_BeforeAttachmentPreview(ByVal Attachment
As Outlook.Attachment, ByRef Cancel As Boolean)
preview = True 'This event will be triggered if the preview pane
is on
End Sub

Private Sub objDocumentItem_BeforeAttachmentRead(ByVal Attachment As
Outlook.Attachment, ByRef Cancel As Boolean)
Dim strUserName As String
Dim olParent As Outlook.DocumentItem
Set olParent = Attachment.Parent
If preview Then
If basLocking.IsLockedDocument(olParent, strUserName) Then
preview = False 'if the document is locked it means that
someone is busy with it
End If
End If
End Sub

Private Sub objDocumentItem_AttachmentRead(ByVal Attachment As
Outlook.Attachment)
Dim intUserResponse As Integer
Dim strClass As String
Dim strUserName As String
Dim olParent As Outlook.DocumentItem
Dim rc As Long, h As Long

On Error GoTo ERROR_objDocumentItem_AttachmentRead
Set olParent = Attachment.Parent
strClass = olParent.MessageClass
If preview Then
'It won't do anything special because it will be shown only so
it shouldn't be locked or unlocked.
Else
'Opens the document in Word or Excel and sets the locking
mechanism
End if
preview = false
end sub

This code works like it should
Only problem is every time when i want to edit a document (so
doubleclick on it)
i get an error saying that if i want to save my changes i should take
"save as".
The first time the document won't open. but the second time i try it.
It opens and i can start editing.
When i save it Outlook crashes and wants to restart itself so i have
no other option then to do that.


Anyone has some suggestions?
Maybe it's best to just turn the preview pane off if it's a document?
but how do i do that in code???
 
S

Sue Mosher [MVP-Outlook]

Sorry, but I don't understand what you're trying to accomplish with this code. Maybe you could give us an overview?

This is perfectly normal if you opened an attachment from the reading pane. Such an attachment is always read-only. Therefore, if you want to save the changes, you must tell Outlook where you want to save them in the file system.
 
A

_-Andy-_

Mm it seems that sometimes the reply doesn't get shown in the
discussiongroup or not that fast :s
i put a reply on yesterday
sorry if this will be the same post again.

i added some events that will be triggered

Private Sub objDocumentItem_BeforeAttachmentPreview(ByVal Attachment
As Outlook.Attachment, ByRef Cancel As Boolean)
preview = True 'This will get triggered if the preview pane /
reading pane is on.
End Sub

Private Sub objDocumentItem_BeforeAttachmentRead(ByVal Attachment As
Outlook.Attachment, ByRef Cancel As Boolean)
Dim strUserName As String
Dim olParent As Outlook.DocumentItem
Set olParent = Attachment.Parent
If preview Then 'This will get triggered between the
BeforeAttachmentPreview and AttachmentRead event. It will check if the
document is locked.
If basLocking.IsLockedDocument(olParent, strUserName) Then 'if
it's locked the locking mechanism will handle it
preview = False
End If
End If
End Sub

Private Sub objDocumentItem_AttachmentRead(ByVal Attachment As
Outlook.Attachment)
Dim intUserResponse As Integer
Dim strClass As String
Dim strUserName As String
Dim olParent As Outlook.DocumentItem
Dim rc As Long, h As Long
On Error GoTo ERROR_objDocumentItem_AttachmentRead
Set olParent = Attachment.Parent
strClass = olParent.MessageClass
If preview Then 'this works like it should i can see the preview
without the document being locked.
'It won't do anything special because it will be shown only so
it shouldn't be locked or unlocked.
Else
'Opens the document in Word or Excel and sets the locking
mechanism
'This will go off if the document is doubleclicked in Outlook.
'This will generate an error saying the file is already been
viewed by some application (Outlook)
'The second time i try to open a document it will open but i
still get an error saying that all changes will be lost if i don't
save as ...
'If i still save it on the original file it will save but
Outlook will crash :s
'I'm assuming this is because outlook had opened the file in
preview and it couldn't handle the new document being saved.
End if
preview = false
end sub

Maybe the best solution is to check if it's a document that is
selected and turn the preview / reading pane off and if it's a normal
email to turn the pane on.
But how do i do that?
I couldn't find that yet :s

Greetings,

Andy
 
A

_-Andy-_

With this code i'm trying to accomplish that multiple users can work
on these documents.
Without the code they can all work on the docuements but they aren't
able to see if anyone is working in it.

So if 2 users are opening the same document the user who saves first
has no problems.
But the second user wants to save but he isn't able too because it has
been changes previously.
So he has to check if he can still do his changes.

With the code i'm writing the users will see behind the filename that
the document is in use by another user
for example
document1.doc # is in use by # Andy

But the preview pane and Outlook 2007 is making it a bit difficult
This was code written for Outlook 2000 and worked up to 2003.
Now i'm changing it for 2007 but i can't seem to handle the
previewpane

How do i get to a tableview in code?
because i think i have to turn it off there right?
I'll have to look into that.
Thanks already for your help.
 
A

_-Andy-_

Hey
this worked for me application.ActiveExplorer.ShowPane olPreview,
False
thanks :D
but now i found another issue :s
If a document is locked by one user it will say # in use by # username
but outlook wants to open the document but my program closes it before
it gets viewed (nasty i know)
But in 2007 outlook opens the document again and i can't stop it :s
or is there a way?
 
S

Sue Mosher [MVP-Outlook]

Sorry, but I can't follow what you're saying about the problem, especially since we don't know how you're "locking" the documents.
 
A

_-Andy-_

Sorry about all the posts :s

The locking is actually just "# in use by # username" behind the
documentname and it all gets checked in the code :s
If you know a better way to lock documents let me know

for now i'll explain how it works.
Well if someone opens the document (doubleclick) it will become locked
(it's in a public folder). You can see it being locked because the
subject of the document changes.
It will add # in use by # username.
Now a second user goes into outlook on another computer and opens the
public folder. He sees the document with "# in use by # username"
behind it but still opens it (doubleclick)
Now i stopped this with the event BeforeAttachmentRead(document,
cancel).
In this event i go and check if the document has "# in use by #
username" in it and if it's not his own username due to bad closing of
outlook or something.
If it is locked by another user i just put cancel = true
so the AttachmentRead event won't be triggered.
I think that should do the trick.
I'll put some code up later on if you want.
 
Top