- ©«¤l
- 2035
- ¥DÃD
- 24
- ºëµØ
- 0
- ¿n¤À
- 2031
- ÂI¦W
- 0
- §@·~¨t²Î
- Win7
- ³nÅ骩¥»
- Office2010
- ¾\ŪÅv
- 100
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2012-3-22
- ³Ì«áµn¿ý
- 2024-2-1
|
¦^´_ 3# a703130
VBA«Ê¸Ë¬°Dllªº¨Ò¤l¡B¤èªk»PÁ`µ²
»s§@DLL®É¡AThisWorkBook¤¤ªº¥N½X«Ê¸Ë¤èªk¦p¤U¡G
1¡B¥´¶}VB6¡A·s«ØActiveX DLL¡Cקï¡u¤uµ{¡v¦WºÙ©M¡uÃþ¼Ò¶ô¡v¦WºÙ¬°»Ýnªº¦WºÙ¡C¥»¨Ò¤¤¡A¤uµ{קאּTestDLL¡AÃþ¼Ò¶ôקאּTest¡C
2¡B«Ø¥ß¤Þ¥Î¡C¤@¯ë»Ýn¤Þ¥ÎMicrosoft Office 11.0 Object Library©MMicrosoft Excel 11.0 Object Library¡C¦pªGVBA¥N½X¤¤ÁÙ¦³¨ä¥L¤Þ¥Î¡A¦bVB¤¤¤]n¹ï¥L̤ޥΡC
3¡B³o¤@¨B´N¬O¨ãÅé«Ê¸Ë¥N½X¤F¡C
¦bè¤~«Ø¥ß¦nªºTestDLL¤¤¡A±N¥N½X©ñ¤JTestÃþ¼Ò¶ô¤¤¡C
¦p«Ê¸ËThisWorkBook¤¤ªºOpen¨Æ¥ó¡G
Sub wbk_open(EApp As Excel.Application, wb As Excel.Workbook, sh As Excel.Worksheet)
'--VBA¤¤»Ýn«Ê¸Ëªº¥DÅé¥N½X
End Sub
¨ä¤¤VBA¤¤ªº¥N½X¬°¨Æ¥ý°µ¦nªºn«Ê¸Ëªº¥N½X¡A¦p¤U±³oÓ¨Ò¤l¡G
'¥´¶}¤u§@Á¡«á¦b·í«eªº¤u§@ªíA1¤¤¿é¤JTest
Private Sub workbook_open()
Cells(1, 1) = "Test"
End Sub
«Ê¸Ë¬°DLLªº¥N½X¬°¡G
Sub wbk_open(EApp As Excel.Application, wb As Excel.Workbook, sh As Excel.Worksheet)
Cells(1, 1) = "Test"
End sub
²{¦b¦bVB6¤¤¥Í¦¨Dll¡A¨ì¦¹´N§¹¦¨«Ê¸Ë¤F¡C
4¡B¦bVBA¤¤¨Ï¥Î«Ê¸Ëªº¥N½X
º¥ý¡A¦bVBA¤¤n¤Þ¥Îè¤~¥Í¦¨ªºTestDll.dll¡C
µM«á·s«Ø¤@Ó¼Ò¶ô¡A¦b¨ä¤¤©w¸q³o¼Ë¤@ÓÅܶqT¡G
Public T As New TestDll.Test
µM«á¦bThisWorkBookªºOpen¤¤¤Þ¥ÎTestDll¤¤ªºTest¡A¥N½X¦p¤U¡G
Private Sub workbook_open()
On Error Resume Next
T.wbk_open Application, ThisWorkbook, ActiveSheet
End Sub
³o¼Ë¨C¦¸¥´¶}Excel«á¡A´N¦bSheet1ªºCells(1,1)¤¤¿é¤J¡uTest¡v¡C
·íµM¡A¦pªG§A·Q¦b²Ä2±i¤u§@ªíªºA1¤¤¿é¤JTest¡A¨º»ò¥i¥H³o¼Ë¥Î¡G
Private Sub workbook_open()
On Error Resume Next
T.wbk_open Application, ThisWorkbook, Sheets(2)
End Sub
¥H¤W´N¬O¥N½X«Ê¸Ëªº¥þ¹Lµ{¡A»Ýnª`·Nªº¬OÅܶqªº¶Ç»¼n¤¬¬Û¹ïÀ³¡C
¤W±¥Ü¨Ò¤¤ªº«Ê¸Ë¥N½X¬O¥Î3ÓÅܶq¶Ç»¼ªº¡A¦pªG¥u¥Î1ÓÅܶq¶Ç»¼¡A¥N½X¦p¤U¡G
'«Ê¸Ë¬°DLLªº¥N½X¬°¡G
Sub wbk_open(sh As Excel.Worksheet)
Cells(1, 1) = "Test"
End sub
'ThisWorkBook¤¤¨Ï¥ÎDllªº¥N½X¬°
Private Sub workbook_open()
On Error Resume Next
T.wbk_open ActiveSheet
End Sub
Dll¤å¥ó©MTest¤å¥ó¡A´ú¸Õ®É½Ð«·s¤Þ¥ÎTestDll.dll |
|