Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Userform shown in windows other than Excel

Hi all,

I use an Excel vba to "upload" data from Excel data to my accounting
software by sendkey command. The steps are 1)real data from Excel cells, 2)
switch the active window to accounting software, 3) use sendkey command to
fill accouting system blank field, 4) switch back to Excel and end

My question is: after switching to accounting system window, can it show a
userform with certain animated gif and text indicating that data is being
input? I can easily manage to show it in excel window, but unsuccessful in
other active windows.

Any help is much appreciated!

Thanks

Alan


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default Userform shown in windows other than Excel

The only way I know to do this (keep a userform created in Excel showing on
top of other apps) is with some Windows API functions, FindWindow and
SetWindowPos; code follows (using elements I got from the MSDN Access
knowledgebase when trying to accomplish something similar in Access):

' Declare the Windows API library functions:
Declare Function FindWindow% Lib "user32" Alias "FindWindowA" _
(ByVal lpclassname As Any, _
ByVal lpCaption As Any)

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

' Declare constants to use as parameters:
Global Const HWND_TOPMOST = -1 ' Puts the Window permanently on top of all
others
Global Const SWP_NOSIZE = &H1 ' Do not resize the Window
Global Const SWP_NOMOVE = &H2 ' Do not move the Window

' Sub to find the userform window
' (by its title: must exactly match the .Caption property of the userform)

Public Sub TopMost(WinCaption As String)
Dim hwnd%
hwnd% = FindWindow%(0&, WinCaption)
Call SetWindowPos(hwnd%, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or
SWP_NOSIZE)
End Sub

You could use this code to activate it:
Userform1.Show ' show your form
TopMost(UserForm1.Caption) ' make it the topmost window

I am not sure if switching to another application and using SendKeys while
this is showing will cause any problems with the display of the form; I
suppose you will have to find that out.
--
- K Dales


"abcsms" wrote:

Hi all,

I use an Excel vba to "upload" data from Excel data to my accounting
software by sendkey command. The steps are 1)real data from Excel cells, 2)
switch the active window to accounting software, 3) use sendkey command to
fill accouting system blank field, 4) switch back to Excel and end

My question is: after switching to accounting system window, can it show a
userform with certain animated gif and text indicating that data is being
input? I can easily manage to show it in excel window, but unsuccessful in
other active windows.

Any help is much appreciated!

Thanks

Alan



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Userform shown in windows other than Excel

Thank you very much. I will try it ^^

"K Dales" ...
The only way I know to do this (keep a userform created in Excel showing
on
top of other apps) is with some Windows API functions, FindWindow and
SetWindowPos; code follows (using elements I got from the MSDN Access
knowledgebase when trying to accomplish something similar in Access):

' Declare the Windows API library functions:
Declare Function FindWindow% Lib "user32" Alias "FindWindowA" _
(ByVal lpclassname As Any, _
ByVal lpCaption As Any)

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

' Declare constants to use as parameters:
Global Const HWND_TOPMOST = -1 ' Puts the Window permanently on top of all
others
Global Const SWP_NOSIZE = &H1 ' Do not resize the Window
Global Const SWP_NOMOVE = &H2 ' Do not move the Window

' Sub to find the userform window
' (by its title: must exactly match the .Caption property of the userform)

Public Sub TopMost(WinCaption As String)
Dim hwnd%
hwnd% = FindWindow%(0&, WinCaption)
Call SetWindowPos(hwnd%, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or
SWP_NOSIZE)
End Sub

You could use this code to activate it:
Userform1.Show ' show your form
TopMost(UserForm1.Caption) ' make it the topmost window

I am not sure if switching to another application and using SendKeys while
this is showing will cause any problems with the display of the form; I
suppose you will have to find that out.
--
- K Dales


"abcsms" wrote:

Hi all,

I use an Excel vba to "upload" data from Excel data to my accounting
software by sendkey command. The steps are 1)real data from Excel cells,
2)
switch the active window to accounting software, 3) use sendkey command
to
fill accouting system blank field, 4) switch back to Excel and end

My question is: after switching to accounting system window, can it show
a
userform with certain animated gif and text indicating that data is being
input? I can easily manage to show it in excel window, but unsuccessful
in
other active windows.

Any help is much appreciated!

Thanks

Alan





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
Convert 29.08 hours (shown in decimal form) to time shown in "hh:m Nila in Florida Excel Worksheet Functions 1 September 14th 08 01:35 AM
Continouse Calc while userform is shown ExcelMonkey Excel Programming 4 February 5th 06 08:36 AM
Userform to enter values and shown in same userform in list helmekki[_104_] Excel Programming 0 November 19th 05 03:23 PM
Userform Shown while macro runs ExcelMonkey[_190_] Excel Programming 3 March 15th 05 05:05 PM
Excel: VBA userform is shown but not loaded/initialized even though it was first unloaded? Luisa[_2_] Excel Programming 2 December 5th 03 08:15 AM


All times are GMT +1. The time now is 03:27 PM.

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

About Us

"It's about Microsoft Excel"