vba改动excel参数
来源:互联网 发布:目前比较火的 js 框架 编辑:程序博客网 时间:2024/05/16 10:23
将标题改为“新标题-工作薄1”
Sub new_title()
Application.Caption = "新标题"
End Sub
让excel的窗口始终显示在最前端
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
--------
The following is the codes from the Microsoft examples for using API.
将 Excel 设置为“总在前面”
下面的示例代码说明如何使 Microsoft Excel“总在前面”。这可以防止其他应用程序
显示在 Microsoft Excel 前面。
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) 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
Global Const HWND_TOPMOST = -1
Global Const HWND_NOTOPMOST = -2
Sub SetOnTop()
Dim WinHnd As Long, SUCCESS As Long
WinHnd = FindWindow("xlmain", Application.Caption)
SUCCESS = SetWindowPos(WinHnd, HWND_TOPMOST, 0, 0, 0, 0, Flags)
'下面一行只是为了 20 秒之后将 Excel 切换回正常操作状态
Application.OnTime Now + TimeValue("00:00:20"), "NotOnTop"
End Sub
Sub NotOnTop()
Dim WinHnd As Long, SUCCESS As Long
WinHnd = FindWindow("xlmain", Application.Caption)
SUCCESS = SetWindowPos(WinHnd, HWND_NOTOPMOST, 0, 0, 0, 0, Flags)
End Sub
------------
The following is the codes from the Microsoft examples for using API.
将 Excel 设置为“总在前面”
下面的示例代码说明如何使 Microsoft Excel“总在前面”。这可以防止其他应用程序
显示在 Microsoft Excel 前面。
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) 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
Global Const HWND_TOPMOST = -1
Global Const HWND_NOTOPMOST = -2
Sub SetOnTop()
Dim WinHnd As Long, SUCCESS As Long
WinHnd = FindWindow("xlmain", Application.Caption)
SUCCESS = SetWindowPos(WinHnd, HWND_TOPMOST, 0, 0, 0, 0, Flags)
'下面一行只是为了 20 秒之后将 Excel 切换回正常操作状态
Application.OnTime Now + TimeValue("00:00:20"), "NotOnTop"
End Sub
Sub NotOnTop()
Dim WinHnd As Long, SUCCESS As Long
WinHnd = FindWindow("xlmain", Application.Caption)
SUCCESS = SetWindowPos(WinHnd, HWND_NOTOPMOST, 0, 0, 0, 0, Flags)
End Sub
- vba改动excel参数
- Excel VBA以单元格区域做参数
- Excel Vba
- excel VBA
- Excel VBA
- EXCEL+VBA
- Excel VBA
- Excel VBA
- Excel VBA
- VBA Excel
- Windows下Batch脚本传递参数给Excel VBA
- Excel中的VBA编程
- VBA for EXCEL FAQ
- Microsoft Excel VBA Examples
- Excel VBA 重要参考
- excel 问题,vba
- EXCEL VBA中的类
- Excel VBA教程
- 接触了Android
- 64位win7禁用驱动程序签名强制 几种常用方法
- MyEclipse8.5优化
- 采用openMP并行方法,实现用分支界限法解决的旅行售货员问题
- discuz 搬家
- vba改动excel参数
- container_of浅析
- STM32的几种延时方法
- VBA常用操作
- 笔记本电脑为android智能机作wifi问题总结
- CodeFirst开发MVC的方法步骤
- OCUnit测试用例配置指南
- SSL入门以及运用Wireshark破解Https(SSL)会话
- discuz 环境配置