Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Code pause when disconnecting from Terminal Services.

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Code pause when disconnecting from Terminal Services.

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Code pause when disconnecting from Terminal Services.


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, wouldnt 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 201
Default Code pause when disconnecting from Terminal Services.

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, wouldnt 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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble Printing from Excel in terminal services snorbens Excel Discussion (Misc queries) 0 October 9th 07 11:09 PM
Pause Code Execution Luke Bailey Excel Programming 2 June 15th 06 08:33 PM
Pause code in vb Greg[_27_] Excel Programming 4 May 9th 06 10:36 PM
VB print to Terminal Services Printer Leslie Excel Programming 0 July 25th 05 10:10 PM
Pause code for data return Candyman Excel Programming 2 January 22nd 05 01:02 AM


All times are GMT +1. The time now is 07:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"