码迷,mamicode.com
首页 > 编程语言 > 详细

vba 新建进程且窗口置顶

时间:2017-10-13 10:05:24      阅读:297      评论:0      收藏:0      [点我收藏+]

标签:open   public   creat   name   declare   set   activate   const   private   

 


Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const SWP_NOACTIVATE = &H10
Const SWP_SHOWWINDOW = &H40
Private Declare Sub 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)
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Public Sub Window_Top() ‘调用API函数,实现窗口最前
Dim WINWND As Long
WINWND = FindWindow(vbNullString, Application.Caption)
SetWindowPos WINWND, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
End Sub

 

Sub CreateApp()

 

Dim wb As Workbook
‘ Set wb = Workbooks.Open("D:/B.xls")

Set app = CreateObject("Excel.Application")
app.Visible = True


app.Workbooks.Open ("C:\vba-test\123.xlsx")


WINWND = FindWindow(vbNullString, app.Caption)
SetWindowPos WINWND, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE

 

 

End Sub

vba 新建进程且窗口置顶

标签:open   public   creat   name   declare   set   activate   const   private   

原文地址:http://www.cnblogs.com/cancelbug/p/7659003.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!