ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] excel vb»yªk ½Ð±Ð

[µo°Ý] excel vb»yªk ½Ð±Ð

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)

        ÀR«ä¦Û¦b : ¬°¦Û¤v§äÂǤfªº¤H¥Ã»·¤£·|¶i¨B¡C
ªð¦^¦Cªí ¤W¤@¥DÃD