- ©«¤l
- 38
- ¥DÃD
- 14
- ºëµØ
- 0
- ¿n¤À
- 58
- ÂI¦W
- 0
- §@·~¨t²Î
- win xp
- ³nÅ骩¥»
- office 2007
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2013-5-22
- ³Ì«áµn¿ý
- 2020-3-9
|
excel §Ú¤w³]¤F¤@Ó«ö¶s ±N¤TÓÄæ¦ìcopy ¨ìaccess
vb½X ¦p¤U °õ¦æ·|µo¥Í¿ù»~ ½Ð±Ð¦U¦ì¤j¤j n¦p¦óקï
Private Sub CommandButton1_Click()
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sql As String
Dim connstr As String
Dim dbPath As String
Dim filePath As String
dbPath = TXT_DATAPATH.Text 'Excel¤å¥ó¸ô?
filePath = TXT_FILEPATH.Text 'MDB¤å¥ó¸ô?
'?±µ?Õu?
'==============================================================================
connstr = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & dbPath
conn.Open connstr
sql = "SELECT * FROM user where id=-1"
rs.Open sql conn 1 3
rs.AddNew
'¥´?excel
'=============================================================================
Set xlApp = CreateObject("Excel.Application") '?«ØEXCEL?¥Î?
xlApp.Visible = False '?¸mEXCEL¤£¥i?
Set xlBook = xlApp.Workbooks.Open(filePath) '¥´?EXCEL¤u§@ï
Set xlSheet = xlBook.Worksheets(1) '¥´?EXCEL¤u§@ªí
'xlApp.Activate '¿E¬¡¤u§@ªí
'´¡¤J?Õu ?¨½»Ýn®ÚÕu§Aexcel¤å¥ó®æ¦¡©Mmdb¤å¥ó®æ¦¡§ï?
'=============================================================================
rs("uname") = xlApp.Range("C4").Value
rs("usex") = xlApp.Range("E4").Value
rs("ubirth") = xlApp.Range("G4").Value
rs("uaddtime") = Now()
'«O¦s
'=============================================================================
rs.Update
rs.Close
'²M²z¤u§@
'=============================================================================
conn.Close
Set rs = Nothing
Set conn = Nothing
xlBook.Close (True) '??EXCEL¤u§@ï
xlApp.Quit '??EXCEL
Set xlApp = Nothing '?©ñEXCEL?¶H
End Sub |
-
-
excel.rar
(20.93 KB)
|