Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel Application to MS Access Application
Hi Everyone
After using below mentioned code i can use excel as an application, but how come i can do the same in access. Thanks' KTS Option Explicit 'API functions 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 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 FindWindow Lib "user32" _ Alias "FindWindowA" _ (ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Private Declare Function GetActiveWindow Lib "user32.dll" _ () As Long 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 DrawMenuBar Lib "user32" _ (ByVal hWnd As Long) As Long 'Constants 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 GWL_STYLE = (-16) Private Const WS_MINIMIZEBOX = &H20000 Private Const SWP_FRAMECHANGED = &H20 Private Const WM_SETICON = &H80 Private Const ICON_SMALL = 0& Private Const ICON_BIG = 1& ------------------------------------------------------------------------------ -- Private Sub UserForm_Activate() AddIcon 'Add an icon on the titlebar AddMinimiseButton 'Add a Minimize button to Userform AppTasklist Me 'Add this userform into the Task bar End Sub ------------------------------------------------------------------------------ -- Private Sub AddIcon() 'Add an icon on the titlebar Dim hWnd As Long Dim lngRet As Long Dim hIcon As Long hIcon = Sheet1.Image1.Picture.Handle hWnd = FindWindow(vbNullString, Me.Caption) lngRet = SendMessage(hWnd, WM_SETICON, ICON_SMALL, ByVal hIcon) lngRet = SendMessage(hWnd, WM_SETICON, ICON_BIG, ByVal hIcon) lngRet = DrawMenuBar(hWnd) End Sub ------------------------------------------------------------------------------ -- Private Sub AddMinimiseButton() '//Add a Minimize button to Userform 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) 'Add this userform into the Task bar 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_QueryClose(Cancel As Integer, CloseMode As Integer) Application.Visible = True End Sub And you need to place the following in a standard module to show a userform. Option Explicit ------------------------------------------------------------------------------ -- Sub Auto_Open() Application.Visible = False UserForm1.Show End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel Application to MS Access Application
On 06/01/2010 15:11, KTS wrote:
Hi Everyone After using below mentioned code i can use excel as an application, but how come i can do the same in access. <snip (after trying the code) Good for quick and dirty but for the forms interface (for both Excel & Access), I'd use another programming environment to do this kind of stuff. Maybe VB or some other .net technology. Access/Excel can still sit behind if you need their data services. You are pushing stuff that can break terribly IMO. -- Adrian C |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel Application to MS Access Application
On 06/01/2010 16:20, Adrian C wrote:
You are pushing stuff that can break terribly IMO. Anyway, here's how. API: Manipulate Access Window http://www.mvps.org/access/api/api0019.htm -- Adrian C |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Excel.Application is not defined error in asp.net application | Excel Programming | |||
Execute a Macro from one excel Application to another Application | Excel Programming | |||
Access to an EXCEL VBa application thru the web? | Excel Programming | |||
macro to close excel application other than application.quit | Excel Programming | |||
Microsoft Excel VB opening Access Application | Excel Programming |