PC Review


Reply
Thread Tools Rate Thread

Code pause when disconnecting from Terminal Services.

 
 
Trefor
Guest
Posts: n/a
 
      18th Nov 2008
I am running some code on a Windows XP PC using Office 2003 and I am
connecting to this PC via Remote Desktop (Terminal Services). While I am
connected everything appears to be fine, but if I disconnect and leave the
remote PC to run by itself I get issues. This code is in an Excel Module that
processes emails from an Outlook folder, so I am not sure if this is an Excel
issue or an Outlook issue, so I have posted this to both discussion groups.

The problems occurs at the line “MessageText = olMail.Body”. Initially I
would get a message saying something about waiting for another OLE process,
after some research I found a reference to using “CoRegisterMessageFilter 0&,
lMsgFilter” to prevent the message being displayed, this appears to work
fine. BUT if you disconnect from the remote PC when the code gets to the line
in question, it just pauses without error. I have left this for 2 days and it
just sits there, if you then connect back in the code resumes and the code
completes without error. It took me ages to find this single line of code
causing the issue and now that I have found it I have no idea what I can try
next. Any ideas?

Public Declare Function CoRegisterMessageFilter Lib "OLE32.DLL" (ByVal
lFilterIn As Long, ByRef lPreviousFilter) As Long
Public lMsgFilter As Long

For ItemReference = MailCount To 1 Step -1

' Get reference to items in folder
On Error Resume Next

Set olMail = InputFolder.Items(ItemReference)

Application.DisplayAlerts = False
CoRegisterMessageFilter 0&, lMsgFilter

MessageText = olMail.Body <<<<<<< Problem occurs here

Application.DisplayAlerts = True
CoRegisterMessageFilter lMsgFilter, lMsgFilter
 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      18th Nov 2008
Make sure omail isn't returning nothing.

For ItemReference = MailCount To 1 Step -1

' Get reference to items in folder
On Error Resume Next

Set olMail = InputFolder.Items(ItemReference)

if not olMail is nothing then
Application.DisplayAlerts = False
CoRegisterMessageFilter 0&, lMsgFilter

MessageText = olMail.Body <<<<<<< Problem occurs here

Application.DisplayAlerts = True
CoRegisterMessageFilter lMsgFilter, lMsgFilter


"Trefor" wrote:

> I am running some code on a Windows XP PC using Office 2003 and I am
> connecting to this PC via Remote Desktop (Terminal Services). While I am
> connected everything appears to be fine, but if I disconnect and leave the
> remote PC to run by itself I get issues. This code is in an Excel Module that
> processes emails from an Outlook folder, so I am not sure if this is an Excel
> issue or an Outlook issue, so I have posted this to both discussion groups.
>
> The problems occurs at the line “MessageText = olMail.Body”. Initially I
> would get a message saying something about waiting for another OLE process,
> after some research I found a reference to using “CoRegisterMessageFilter 0&,
> lMsgFilter” to prevent the message being displayed, this appears to work
> fine. BUT if you disconnect from the remote PC when the code gets to the line
> in question, it just pauses without error. I have left this for 2 days and it
> just sits there, if you then connect back in the code resumes and the code
> completes without error. It took me ages to find this single line of code
> causing the issue and now that I have found it I have no idea what I can try
> next. Any ideas?
>
> Public Declare Function CoRegisterMessageFilter Lib "OLE32.DLL" (ByVal
> lFilterIn As Long, ByRef lPreviousFilter) As Long
> Public lMsgFilter As Long
>
> For ItemReference = MailCount To 1 Step -1
>
> ' Get reference to items in folder
> On Error Resume Next
>
> Set olMail = InputFolder.Items(ItemReference)
>
> Application.DisplayAlerts = False
> CoRegisterMessageFilter 0&, lMsgFilter
>
> MessageText = olMail.Body <<<<<<< Problem occurs here
>
> Application.DisplayAlerts = True
> CoRegisterMessageFilter lMsgFilter, lMsgFilter
> .
> .
> .
> .
> Next ItemReference
>
> --
> Trefor

 
Reply With Quote
 
Trefor
Guest
Posts: n/a
 
      18th Nov 2008

Joel,

Thankyou for your reply. I can try this, but this does not explain my
symptoms:

1. If I run on my PC, no issues.
2. If I remotely connect to another PC, no issues.
3. If I disconnect from the remote PC, the code stops at “MessageText =
olMail.Body”
4. If I reconnect to the remote PC, the code will resume without error and
without intervention.

If what you indicate is true, wouldn’t it fail all the time?

--
Trefor


"Joel" wrote:

> Make sure omail isn't returning nothing.
>
> For ItemReference = MailCount To 1 Step -1
>
> ' Get reference to items in folder
> On Error Resume Next
>
> Set olMail = InputFolder.Items(ItemReference)
>
> if not olMail is nothing then
> Application.DisplayAlerts = False
> CoRegisterMessageFilter 0&, lMsgFilter
>
> MessageText = olMail.Body <<<<<<< Problem occurs here
>
> Application.DisplayAlerts = True
> CoRegisterMessageFilter lMsgFilter, lMsgFilter
>
>
> "Trefor" wrote:
>
> > I am running some code on a Windows XP PC using Office 2003 and I am
> > connecting to this PC via Remote Desktop (Terminal Services). While I am
> > connected everything appears to be fine, but if I disconnect and leave the
> > remote PC to run by itself I get issues. This code is in an Excel Module that
> > processes emails from an Outlook folder, so I am not sure if this is an Excel
> > issue or an Outlook issue, so I have posted this to both discussion groups.
> >
> > The problems occurs at the line “MessageText = olMail.Body”. Initially I
> > would get a message saying something about waiting for another OLE process,
> > after some research I found a reference to using “CoRegisterMessageFilter 0&,
> > lMsgFilter” to prevent the message being displayed, this appears to work
> > fine. BUT if you disconnect from the remote PC when the code gets to the line
> > in question, it just pauses without error. I have left this for 2 days and it
> > just sits there, if you then connect back in the code resumes and the code
> > completes without error. It took me ages to find this single line of code
> > causing the issue and now that I have found it I have no idea what I can try
> > next. Any ideas?
> >
> > Public Declare Function CoRegisterMessageFilter Lib "OLE32.DLL" (ByVal
> > lFilterIn As Long, ByRef lPreviousFilter) As Long
> > Public lMsgFilter As Long
> >
> > For ItemReference = MailCount To 1 Step -1
> >
> > ' Get reference to items in folder
> > On Error Resume Next
> >
> > Set olMail = InputFolder.Items(ItemReference)
> >
> > Application.DisplayAlerts = False
> > CoRegisterMessageFilter 0&, lMsgFilter
> >
> > MessageText = olMail.Body <<<<<<< Problem occurs here
> >
> > Application.DisplayAlerts = True
> > CoRegisterMessageFilter lMsgFilter, lMsgFilter
> > .
> > .
> > .
> > .
> > Next ItemReference
> >
> > --
> > Trefor

 
Reply With Quote
 
Trefor
Guest
Posts: n/a
 
      29th Nov 2008
Joel,

I made these changes as suggested and it did not make any difference. I note
that if there is no “outlook interaction” required 2 hours worth of
processing goes through unattended without issue. If there are emails to
process and I am not connected the code just stalls until I reconnect.

--
Trefor


"Trefor" wrote:

>
> Joel,
>
> Thankyou for your reply. I can try this, but this does not explain my
> symptoms:
>
> 1. If I run on my PC, no issues.
> 2. If I remotely connect to another PC, no issues.
> 3. If I disconnect from the remote PC, the code stops at “MessageText =
> olMail.Body”
> 4. If I reconnect to the remote PC, the code will resume without error and
> without intervention.
>
> If what you indicate is true, wouldn’t it fail all the time?
>
> --
> Trefor
>
>
> "Joel" wrote:
>
> > Make sure omail isn't returning nothing.
> >
> > For ItemReference = MailCount To 1 Step -1
> >
> > ' Get reference to items in folder
> > On Error Resume Next
> >
> > Set olMail = InputFolder.Items(ItemReference)
> >
> > if not olMail is nothing then
> > Application.DisplayAlerts = False
> > CoRegisterMessageFilter 0&, lMsgFilter
> >
> > MessageText = olMail.Body <<<<<<< Problem occurs here
> >
> > Application.DisplayAlerts = True
> > CoRegisterMessageFilter lMsgFilter, lMsgFilter
> >
> >
> > "Trefor" wrote:
> >
> > > I am running some code on a Windows XP PC using Office 2003 and I am
> > > connecting to this PC via Remote Desktop (Terminal Services). While I am
> > > connected everything appears to be fine, but if I disconnect and leave the
> > > remote PC to run by itself I get issues. This code is in an Excel Module that
> > > processes emails from an Outlook folder, so I am not sure if this is an Excel
> > > issue or an Outlook issue, so I have posted this to both discussion groups.
> > >
> > > The problems occurs at the line “MessageText = olMail.Body”. Initially I
> > > would get a message saying something about waiting for another OLE process,
> > > after some research I found a reference to using “CoRegisterMessageFilter 0&,
> > > lMsgFilter” to prevent the message being displayed, this appears to work
> > > fine. BUT if you disconnect from the remote PC when the code gets to the line
> > > in question, it just pauses without error. I have left this for 2 days and it
> > > just sits there, if you then connect back in the code resumes and the code
> > > completes without error. It took me ages to find this single line of code
> > > causing the issue and now that I have found it I have no idea what I can try
> > > next. Any ideas?
> > >
> > > Public Declare Function CoRegisterMessageFilter Lib "OLE32.DLL" (ByVal
> > > lFilterIn As Long, ByRef lPreviousFilter) As Long
> > > Public lMsgFilter As Long
> > >
> > > For ItemReference = MailCount To 1 Step -1
> > >
> > > ' Get reference to items in folder
> > > On Error Resume Next
> > >
> > > Set olMail = InputFolder.Items(ItemReference)
> > >
> > > Application.DisplayAlerts = False
> > > CoRegisterMessageFilter 0&, lMsgFilter
> > >
> > > MessageText = olMail.Body <<<<<<< Problem occurs here
> > >
> > > Application.DisplayAlerts = True
> > > CoRegisterMessageFilter lMsgFilter, lMsgFilter
> > > .
> > > .
> > > .
> > > .
> > > Next ItemReference
> > >
> > > --
> > > Trefor

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code pause when disconnecting from Terminal Services. Trefor Microsoft Outlook VBA Programming 0 18th Nov 2008 08:35 AM
Errors- HTTP, Terminal Services, TBS, DPS, UAC, Code Integrity, WM Gaurav Windows Vista General Discussion 3 27th Mar 2008 05:21 PM
Mapping my Terminal Services User Profile to my Terminal Services Home Folder neil.harvey@hen.invesco.com Microsoft Windows 2000 Group Policy 0 20th Apr 2007 11:41 AM
Terminal Services Clients Consume Multiple Terminal Services CALs =?Utf-8?B?Y2JsYWNr?= Microsoft Windows 2000 Terminal Server Clients 0 27th Apr 2005 11:24 PM
Terminal Server and connected Terminal Services clients pause while working Neeraj Microsoft Windows 2000 Terminal Server Applications 1 1st Sep 2004 03:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:18 AM.