????? ??????? ???? ?? Access ??? Excel ???????? DAO

?????? ????????? ?????? ?????????
???? ???????: 146406 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

??????

?? ??????? Microsoft Excel ???????? ?????? ????? ??????? ?????? ?????? ??? ???????? (DAO) ?? Visual Basic for Applications ??????? ???? ?? Microsoft Access.

?????? ???? ?? ????? ??????? DAO ??????? ???? ?? Microsoft Access ????? ??????? ?? ??? ??????? ?????? ????? ?????? Northwind ??????? ?? ?? Microsoft Office Professional ?? Windows 95 ? ??????? 7.0 ? Microsoft Office 97 Professional ?? Windows. ??? ??? ?????? ???????? ?????????? ??? ????? Microsoft Office Professional ?? Windows 95 ? ??????? 7.0 ? ????? ???????? ???????? ??:
   \MSOffice\Access\Samples\Northwind.mdb
				
??? ??? ?????? ???????? ?????????? ??? ????? Microsoft Office 97 Professional ?? Windows ????? ???????? ???????? ??:
   \Program Files\Microsoft Office\Office\Samples\Northwind.mdb
				
??? ???? ????? ???????? Northwind ?? ???? ??? ??? ????????? ????? ?? ?????? ??? ????? ????????? ???????? ???????? ????? ??? ?? ???? ??????.

??? ?? ???? ????? ?????? DAO Microsoft ???????? DAO ?? ??????? ????? ?? ?? ?? ???? ????? ????? "???? ?? ??? ???????? ??? ??? ?????". ??? ??? ??????? ?? Microsoft Excel ??????? 7.0 ? ????? ???? ???? ????? ???? ??? "?????" ?? ????? "?????" ?? ??? ?????? "????? ?????? 3.0 DAO Microsoft". ??? ??? ??????? ?? Microsoft Excel 97 ??????? ? ???? "?????" ?? ??????? "?????" ?? "???? Visual Basic ?? ???? ??"DAO 3.5 ????? ?????? Microsoft".

??????? ????

???? Microsoft ??????? ???????? ??? ??? ?? ???? ??????? ?? ?? ?????. ??? ????? ???? ?? ????? ??? ???????? ??????? ?????? ???????? ?? ???????? ???? ????. ????? ??? ??????? ???? ?????? ?? ??? ??????? ???? ??? ????? ?? ??????? ???? ??? ????????? ?????? ?????? ?????????. ???? ??????? ????? ??? Microsoft ??? ????? ????? ???? ???? ?? ?????? ?????? ??? ??????? ?????? ????? ?????? ?? ????? ??????? ?????? ??????? ?????. ???????? ???? ?? Microsoft Access? ???? ??????? ???????:

  1. ????? ???? ????? ??????.
  2. ????? ???? Recordset.
  3. ??????? ?????? ?? (??? ???? ????).
  4. ??????? ???????? ?? ??????.
??? ??????? ???????? ??? ????? ???? ???????? ????? ?????? ????? ????? .Close.

???????? ???? ?? Microsoft Access ??????? ??????? Visual Basic ????????? ???????? ?????????:
Sub GetTable()
'This sub will retrieve all the data in the "Customers" table in
'Northwind

   'Declare variables
   Dim Db As Database
   Dim Rs As Recordset
   Dim Ws As Object
   Dim i As Integer
   Dim Path as String

   'This line will define the Object "Ws" as Sheets("Sheet1")
   'The purpose of this is to save typing Sheets("Sheet1")
   'over and over again
   Set Ws = Sheets("Sheet1")

   'Set the Path to the database. This line is useful because
   'if your database is in another location, you just need to change
   'it here and the Path Variable will be used throughout the code
   Path = "c:\msoffice\access\samples\northwind.mdb"

   'This set of code will activate Sheet1 and clear any existing data
   'After clearing the data it will select cell A1
   Ws.Activate
   Range("A1").Activate
   Selection.CurrentRegion.Select
   Selection.ClearContents
   Range("A1").Select

   'Set the Database, and RecordSet  This Table exists in the database
   Set Db = Workspaces(0).OpenDatabase(Path, ReadOnly:=True)

   'This will set the RecordSet to all records in the Customers table
   Set Rs = Db.OpenRecordset("Customers")

   'You could instead set the RecordSet to, for example, the records
   'where the Country Code is "UK", without quotes. To do this, replace
   'the line above: Set Rs = Db.OpenRecordset("Customers") with the
   'following:
   '
   'Set Rs = _
   'Db.OpenRecordset("SELECT * FROM Customers WHERE Country = 'UK';")


   'This loop will collect the field names and place them in the first
   'row starting at "A1"
   For i = 0 To Rs.Fields.Count - 1
      Ws.Cells(1, i + 1).Value = Rs.Fields(i).Name
   Next I

   'The next line simply formats the headers to bold font
   Ws.Range(Ws.Cells(1, 1), Ws.Cells(1, Rs.Fields.Count)).Font.Bold=True

   'The next line will get the data from the recordset and copy it
   'into the Worksheet (Sheet1).
   Ws.Range("A2").CopyFromRecordset Rs

   'This next code set will just select the data region and
   'auto-fit the columns
   Sheets("Sheet1").Select
   Range("A1").Select
   Selection.CurrentRegion.Select
   Selection.Columns.AutoFit
   Range("A1").Select

   Rs.Close
   Db.Close
End Sub
				

?????

????? ?? ????????? ??? "?????? ??? ????????" ???? ??? ????? ??????? "????" ?? ??????? Microsoft Excel ? ???? ???? ??????
?????? ??? ???????? ?? DAO
??? ?? ???? ????? ??????? ??? ???? ?????? ??? ???????? ??? ????? "?????? ??? ?????? ????? ???????? ???????? DAO".

???????

???? ???????: 146406 - ????? ??? ??????: 18/?????/1427 - ??????: 2.3
????? ???
  • Microsoft Excel 97 Standard Edition
  • Microsoft Excel 95 Standard Edition
????? ??????: 
kbmt kbdtacode kbhowto kbinterop kbprogramming KB146406 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????146406
????? ??????? ?? ????? ???? ?? ????? ???????
?? ????? ????? ?????? ???? ???? ???? ??? ??????? ??? ?? ? ?? ??? ??????? Microsoft ??? ????? ??? ??????? ????? ?????? ?????

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com