View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Milothicus[_4_] Milothicus[_4_] is offline
external usenet poster
 
Posts: 1
Default Need to Wait for 'Print' or 'Close' (VBA)


Robert Bruce Wrote:
Roedd <<Milothicus wedi ysgrifennu:
OK. It looks like you're doing COM automation without knowing it. Stick
it
on your CV.

Woohoo! i have job skills!


Put the declaration (Private Declare Function etc.) at the top of a
regular
bas module. If you are going to call it from a different module, change
the
declaration from Private to Public.

Now, find where you are starting up your Excel instance (either set
[variable] = new Excel.Application or CreateObject(...). Put the line

CoRegisterMessageFilter 0&, lngMsgFilter

just before it. Now find where you are destroying your Excel instance
([variable].Quit: set Excel = nothing) and put the line

CoRegisterMessageFilter lngMsgFilter, lngMsgFilter

just after it. You will also need to declare the lngMsgFilter variable
in
your routine. This will stop the message appearing when solidworks
thinks
that Excel has stopped responding. You could experiment with putting
these
lines just before and after where you call the printpreview if you are
worried about loosing all messages should Excel hang for another
reason.


the event i mentioned above is attached to the workbook.

there must
be a way to use the event in the workbook code to set a variable to
'true' in the solidworks code.


There is, but I don't think it would help, since the message you are
seeing
is raised from deep under the hood.

Fair enough.

could i send keystrokes with one to be received by the

other?
Don't do that.

I'll avoid it like the plague.

Thanks for the help. your explanation makes sense to me now. so does
your suggestion just apply a filter to messages that doesn't allow any
through?



--
Milothicus
------------------------------------------------------------------------
Milothicus's Profile: http://www.excelforum.com/member.php...o&userid=15121
View this thread: http://www.excelforum.com/showthread...hreadid=378923