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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Have Accpac Macros appears in the Taskbar 3

Status
Not open for further replies.

kenaruj

Programmer
Jun 2, 2006
16
US
Is it possible to have Accpac macros appear in the taskbar? Oftentimes, I'll be running a macro and click on another window and the macro gets lost behind the other windows. It would be nice to have the macro appear in the taskbar (like all other applications) when ran.

If there isn't currently a solution to this, is there much demand?

Thanks
 
It's just the way VBA functions, there's not much you can do about it.
Press ALT-TAB will list the macro though.
If you really want to see something in the task bar then convert the macro to VB, but that is way too much effort for most macros.
 
It is possible to have Accpac Macros appear in the taskbar but it requires several API functions and adds a bit of overhead to your code. Using VB6 is the ideal solutions for this issue. If you still really want to have your VBA macros show up in the task bar let me know and I'll post the code.
 
jmainland, that sounds interesting.
Do you mind sharing some code?
 
This code will make the vba form appear in the task bar. It also gives it a minimize button as well.

'GENERAL DECLARATIONS

'API
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long

Private Declare Function FindWindow _
Lib "user32" _
Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) _
As Long

Private Declare Function GetWindowLong _
Lib "user32" _
Alias "GetWindowLongA" ( _
ByVal hWnd As Long, _
ByVal nIndex As Long) _
As Long

Private Declare Function SetWindowLong _
Lib "user32" _
Alias "SetWindowLongA" ( _
ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) _
As Long

Private Declare Function DrawMenuBar _
Lib "user32" ( _
ByVal hWnd As Long) _
As Long

Private Declare Function SetWindowPos Lib "user32" _
(ByVal hWnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal x As Long, _
ByVal Y As Long, _
ByVal cx As Long, _
ByVal cy As Long, _
ByVal wFlags As Long) As Long

Private Declare Function GetActiveWindow Lib "user32.dll" _
() As Long

Private Const GWL_STYLE As Long = (-16)
Private Const WS_SYSMENU As Long = &H80000
Private Const WS_MINIMIZEBOX As Long = &H20000
Private Const WS_MAXIMIZEBOX As Long = &H10000

Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const GWL_EXSTYLE = (-20)
Private Const HWND_TOP = 0
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_HIDEWINDOW = &H80
Private Const SWP_SHOWWINDOW = &H40
Private Const WS_EX_APPWINDOW = &H40000
Private Const SWP_FRAMECHANGED = &H20
Private Const WM_SETICON = &H80
Private Const ICON_SMALL = 0&
Private Const ICON_BIG = 1&


Private Sub AddMinimiseButton()
Dim hWnd As Long
hWnd = GetActiveWindow
Call SetWindowLong(hWnd, GWL_STYLE, _
GetWindowLong(hWnd, GWL_STYLE) Or _
WS_MINIMIZEBOX)
Call SetWindowPos(hWnd, 0, 0, 0, 0, 0, _
SWP_FRAMECHANGED Or _
SWP_NOMOVE Or _
SWP_NOSIZE)
End Sub

Private Sub AppTasklist(myForm)
Dim WStyle As Long
Dim Result As Long
Dim hWnd As Long

hWnd = FindWindow(vbNullString, myForm.Caption)
WStyle = GetWindowLong(hWnd, GWL_EXSTYLE)
WStyle = WStyle Or WS_EX_APPWINDOW
Result = SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, _
SWP_NOMOVE Or _
SWP_NOSIZE Or _
SWP_NOACTIVATE Or _
SWP_HIDEWINDOW)
Result = SetWindowLong(hWnd, GWL_EXSTYLE, WStyle)
Result = SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, _
SWP_NOMOVE Or _
SWP_NOSIZE Or _
SWP_NOACTIVATE Or _
SWP_SHOWWINDOW)
End Sub


Private Sub UserForm_Activate()
AddMinimiseButton
AppTasklist Me
End Sub
 
Thanks, that certainly is helpful.
I had the one to add the Min and Max buttons, so now I display the macro in the taskbar as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top