ExcelHome技术论坛

 找回密码
 免费注册

QQ登录

只需一步,快速开始

快捷登录

搜索
EH技术汇-专业的职场技能充电站 妙哉!函数段子手趣味讲函数 Excel服务器-会Excel,做管理系统 效率神器,一键搞定繁琐工作
HR薪酬管理数字化实战 Excel 2021函数公式学习大典 Excel数据透视表实战秘技 打造核心竞争力的职场宝典
让更多数据处理,一键完成 数据工作者的案头书 免费直播课集锦 ExcelHome出品 - VBA代码宝免费下载
用ChatGPT与VBA一键搞定Excel WPS表格从入门到精通 Excel VBA经典代码实践指南
查看: 6304|回复: 19

[分享]技巧分享

[复制链接]

TA的精华主题

TA的得分主题

发表于 2005-6-25 11:30 | 显示全部楼层 |阅读模式

IF 如果本贴所列技巧可以对你的工作或学习有所帮助 Then

Msgbox "那将是俺引以为荣的事情"

Elseif 如果你可以把自己的技巧拿出来分享 Then

Msgbox " 这是俺最高兴看到的事"

Else

Msgbox "为了保持贴子的可读性,请不要灌水,谢谢!"

End if

[此贴子已经被作者于2005-6-25 12:53:19编辑过]

TA的精华主题

TA的得分主题

 楼主| 发表于 2005-6-25 11:34 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助

列表:

3楼: 如何用代码设置ACCESS的选项.

4楼: 用API 改变ACCESS主窗口的灰色背景.

8楼:自动填入值的两种方法。

11楼:打开对话框,选择文件,保存文件路径

[此贴子已经被作者于2005-7-19 10:42:28编辑过]

TA的精华主题

TA的得分主题

 楼主| 发表于 2005-6-25 12:30 | 显示全部楼层

记得初学ACCESS时,学习过“东迪ERP”系统,在系统的安装中,明确说明“要确保系统的正常运行,必需设置选项中的…….“那时开始认识ACCESS选项的作用。后来学习VBA才知道原来ACCESS的选项是可以在VBA中设置。下面的代码是我系统中设置的选项,关于其它选项可查联机帮助,当然我也非常乐意为你解答。

'设置确认记录更改,删除,执行操作查询等 Public Sub AppSon() Application.SetOption "Confirm Record Changes", False '确认,记录更改 Application.SetOption "Confirm Document Deletions", False '确认,删除文档 Application.SetOption "Confirm Action Queries", False '确认,操作查询 Application.SetOption "Show Hidden Objects", False '显示隐藏对像 Application.SetOption "Show System Objects", False '显示系统对像 Application.SetOption "ShowWindowsInTaskbar", False '任务栏中显示打开的窗口 Application.SetOption "Auto Compact", True '关闭时压缩 End Sub

TA的精华主题

TA的得分主题

 楼主| 发表于 2005-6-25 13:27 | 显示全部楼层

在我早期开发的软件中,最遗憾的事莫过于ACCESS主窗口难看的灰色背景,它使ACCESS开发的软件和其它软件相比起来,总有一种摆脱不了的“土”。也曾尝试过用背景窗口,弹出窗体,无边框窗体等方法,但都有一定的局限性,下面的代码可以使你的ACCESS软件告别“土系统“。

Option Compare Database'改变ACCESS 主窗口背景颜色公用模块中的代码 Option Explicit

Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type

Private Type SIZEL cx As Long cy As Long End Type

Private Type RGBQUAD rgbBlue As Byte rgbGreen As Byte rgbRed As Byte rgblReserved As Byte End Type

Private Type BITMAPINFOHEADER '40 bytes biSize As Long ' 40 biWidth As Long ' 32 biHeight As Long ' 64 biPlanes As Integer '1 biBitCount As Integer '1 biCompression As Long 'ERGBCompression biSizeImage As Long biXPelsPerMeter As Long biYPelsPerMeter As Long biClrUsed As Long biClrImportant As Long End Type

Private Type BITMAPINFO bmiHeader As BITMAPINFOHEADER bmiColors(1) As RGBQUAD End Type

Private Type BITMAP bmType As Long bmWidth As Long bmHeight As Long bmWidthBytes As Long bmPlanes As Integer bmBitsPixel As Integer bmBits As Long End Type

' Logical Brush (or Pattern) Private Type LOGBRUSH lbStyle As Long lbColor As Long lbHatch As Long End Type

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

Private Declare Function DeleteDC Lib "gdi32" (ByVal hDC As Long) As Long

Private Declare Function apiGetDeviceCaps Lib "gdi32" _ Alias "GetDeviceCaps" (ByVal hDC As Long, ByVal nIndex As Long) As Long

Private Declare Function CreateSolidBrush Lib "gdi32" _ _ (ByVal crColor As Long) As Long

Private Declare Function DeleteObject Lib "gdi32" _ (ByVal hObject As Long) As Long

Private Declare Function GetStockObject Lib "gdi32" _ (ByVal nIndex As Long) As Long

Private Declare Function SetClassLong Lib "user32" Alias "SetClassLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long

Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long

Private Declare Function InvalidateRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT, ByVal bErase As Long) As Long

' Class field offsets for GetClassLong() and GetClassWord() Private Const GCL_MENUNAME = (-8) Private Const GCL_HBRBACKGROUND = (-10) Private Const GCL_HCURSOR = (-12) Private Const GCL_HICON = (-14) Private Const GCL_HMODULE = (-16) Private Const GCL_CBWNDEXTRA = (-18) Private Const GCL_CBCLSEXTRA = (-20) Private Const GCL_WNDPROC = (-24) Private Const GCL_STYLE = (-26) Private Const GCW_ATOM = (-32)

' Stock Logical Objects Private Const WHITE_BRUSH = 0 Private Const LTGRAY_BRUSH = 1 Private Const GRAY_BRUSH = 2 Private Const DKGRAY_BRUSH = 3 Private Const BLACK_BRUSH = 4 Private Const NULL_BRUSH = 5 Private Const HOLLOW_BRUSH = NULL_BRUSH

Private Const CLR_INVALID = &HFFFF

' Brush Styles Private Const BS_SOLID = 0 Private Const BS_NULL = 1 Private Const BS_HOLLOW = BS_NULL Private Const BS_HATCHED = 2 Private Const BS_PATTERN = 3 Private Const BS_INDEXED = 4 Private Const BS_DIBPATTERN = 5 Private Const BS_DIBPATTERNPT = 6 Private Const BS_PATTERN8X8 = 7 Private Const BS_DIBPATTERN8X8 = 8

' Hatch Styles Private Const HS_HORIZONTAL = 0 ' 中国人

Private Const HS_VERTICAL = 1 ' QQ:404001992

Private Const HS_FDIAGONAL = 2 ' 欢迎大家交流 ' ///// Private Const HS_CROSS = 4 ' +++++ Private Const HS_DIAGCROSS = 5 ' xxxxx Private Const HS_FDIAGONAL1 = 6 Private Const HS_BDIAGONAL1 = 7 Private Const HS_SOLID = 8 Private Const HS_DENSE1 = 9 Private Const HS_DENSE2 = 10 Private Const HS_DENSE3 = 11 Private Const HS_DENSE4 = 12 Private Const HS_DENSE5 = 13 Private Const HS_DENSE6 = 14 Private Const HS_DENSE7 = 15 Private Const HS_DENSE8 = 16 Private Const HS_NOSHADE = 17 Private Const HS_HALFTONE = 18 Private Const HS_SOLIDCLR = 19 Private Const HS_DITHEREDCLR = 20 Private Const HS_SOLIDTEXTCLR = 21 Private Const HS_DITHEREDTEXTCLR = 22 Private Const HS_SOLIDBKCLR = 23 Private Const HS_DITHEREDBKCLR = 24 Private Const HS_API_MAX = 25

Private Const TITLE = "" Private Const API_TRUE As Long = 1& ' Handle to original WINDOWCLASS Brush for MDI window Private prevHBrush As Long ' Handle to our new Brush for the MDI window Private hBrush As Long

' Handle to MDI window Private HwndMDI As Long

Public Function SetMDIBackGround(ByVal crColor As Long) As Boolean ' junk var Dim lngRet As Long

' Window Rect Dim rc As RECT

' Grab the Stock WHITE brush 'hBrush = GetStockObject(WHITE_BRUSH) hBrush = CreateSolidBrush(crColor)

' find MDIClient first HwndMDI = FindWindowEx(Application.hWndAccessApp, 0&, "MDIClient", TITLE) ' Get current dimensions lngRet = GetWindowRect(HwndMDI, rc)

With rc .Bottom = .Bottom - .Top .Top = 0 .Right = .Right - .Left .Left = 0 End With prevHBrush = SetClassLong(HwndMDI, GCL_HBRBACKGROUND, hBrush) ' Force a redraw Call InvalidateRect(HwndMDI, rc, API_TRUE) SetMDIBackGround = True End Function

Public Sub Apibj() Dim blRet As Boolean blRet = SetMDIBackGround(1652585884)'括号中的数字是需要的背景颜色值 End Sub

****************** 调用方法:直接调用APIBJ

[此贴子已经被作者于2005-10-2 0:01:10编辑过]

TA的精华主题

TA的得分主题

发表于 2005-6-25 16:05 | 显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件       ★免费下载 ★       ★ 使用帮助

佩服,佩服;欣赏,欣赏!

一份奉献;无数收获!

TA的精华主题

TA的得分主题

发表于 2005-6-25 22:19 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册

Public Sub 谢谢() Dim name As String name = InputBox("输入你的名字")

MsgBox "谢谢您分享的技巧" & name

end sub

初学VBA,谢谢分享.

TA的精华主题

TA的得分主题

发表于 2005-6-28 22:15 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册

“中国深圳”你历害,牛!!!

TA的精华主题

TA的得分主题

 楼主| 发表于 2005-6-29 10:47 | 显示全部楼层

自动填入数值的两种方法

TG7u7UMf.rar (35.7 KB, 下载次数: 101)

在数据库中,为了节省存储空间或提高输入效率,某些情况下,我们需要一些数据可以根据现有的条件自动显示. 现介绍两种方法来实现:

TA的精华主题

TA的得分主题

发表于 2005-6-29 21:36 | 显示全部楼层
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用  · 内置多项VBA编程加强工具       ★ 免费下载 ★      ★使用手册
8楼的方法类似excel的数据有效性,学习了。

TA的精华主题

TA的得分主题

发表于 2005-6-29 22:10 | 显示全部楼层
中国深圳是个难得的高手,有问必答,值得大家学习。
您需要登录后才可以回帖 登录 | 免费注册

本版积分规则

手机版|关于我们|联系我们|ExcelHome

GMT+8, 2024-12-26 09:38 , Processed in 0.040905 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 1999-2023 Wooffice Inc.

沪公网安备 31011702000001号 沪ICP备11019229号-2

本论坛言论纯属发表者个人意见,任何违反国家相关法律的言论,本站将协助国家相关部门追究发言者责任!     本站特聘法律顾问:李志群律师

快速回复 返回顶部 返回列表