Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Impromptu Macro 1

Status
Not open for further replies.

geordon

Programmer
Feb 25, 2004
1
CA
How do I display brief description of each function as it runs when running macro that has 12 functions. I want to do this so I can at anytime see where it is at
 
I think you should be able to use a message box as soon as you call a function. Hopefully this helps.
 
geordon,

There is no built-in capability to do this that does not stop the macro from processing while the message appears. Cognos has an example of an ActiveX control, ShowStatus, that you can create to give status message while the macro continues processing.

If you have VB 5 or greater and access to the Cognos support site, do a search in SupportLink past editions on "ShowStatus" and you should get the source code. I've used it and it works, but you have to be able to register the control on each workstation that runs it.

Regards,

Dave Griffin


The Decision Support Group
Reporting Consulting with Cognos BI Tools
"Magic with Data"
[pc2]
Want good answers? Read FAQ401-2487 first!
 
Hi Geordon,

I've never use ActiveX control ShowStatus but if you have a dialog you can create a status information zone that' define a label field and you change label to show information to user. In this case, process can't stop like message box. I do this and it works good. If you don't have dialog box create one just to show message.

Gilles.
 
Gilles,

Can you post sample code on this? My understanding is that only the dialog function continues to run while the dialog is visible. I'd be very interested if you know of a way around this short of putting all executing code in the dialog function.

Regards,

Dave Griffin


The Decision Support Group
Reporting Consulting with Cognos BI Tools
"Magic with Data"
[pc2]
Want good answers? Read FAQ401-2487 first!
 
Dave, Geordon

Try this code and tell me if it's OK. It works for me.
Geordon, you can replace your function call where macro's sleep 5 sec.

Gilles.

======================================================
Option Explicit
Option Base 1

Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)

Declare Function GestionDialgImprs (IdObjet as string, _
Action as integer, _
Valeur as long) as integer

Dim Mesg as string
Dim EndDialog as integer

SUB MAIN()

On Error Goto GestnErr

EndDialog = 0
Mesg = "Initialisation"

Begin Dialog DialgBox 144, 155, 333, 70, .GestionDialgImprs
OkButton 261, 8, 50, 14, .ctrOK
CancelButton 261, 36, 50, 14, .ctrCancel
GroupBox 2, 1, 193, 48, "Information Zone"
Text 8, 10, 181, 28, "" , .InforMesg
End Dialog

Dim DialgInstall As DialgBox

While (EndDialog = 0)
Dialog DialgInstall
WEND

GestnErr:


END SUB

Function GestionDialgImprs (IdObjet as string, _
Action as integer, _
Valeur as long) as integer

Select Case Action
Case 1 'Initialisation de la boîte de dialogue
dlgText dlgControlID("InforMesg"), Mesg

Case 2
Select Case DlgFocus
Case "ctrOK"
dlgText dlgControlID("InforMesg"), "First function"
'Call your first function, for example we will wait 5 seconds
Call Sleep (5000)
dlgText dlgControlID("InforMesg"), "Second function"
'Call your second function, for example we will wait 5 seconds
Call Sleep (5000)
dlgText dlgControlID("InforMesg"), "Third function"
'Call your third function, for example we will wait 5 seconds
Call Sleep (5000)
Mesg = "Functions completed"
End Select
End Select

End Function
 
Gilles,

It does work, but as I feared it requires a significant re-write of existing macros to run from within the dialog function. Still, it is better than ShowStatus. I'll look into using it for longer-running macros in the future.

Thanks! (And a Star for a potentially VERY useful tip)

Dave Griffin




The Decision Support Group
Reporting Consulting with Cognos BI Tools
"Magic with Data"
[pc2]
Want good answers? Read FAQ401-2487 first!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top