Import data from html to Access 2002 (OX sr1)
กระทู้เก่าบอร์ด อ.สุภาพ ไชยา

 215   1
URL.หัวข้อ / URL
Import data from html to Access 2002 (OX sr1)

มีคนถามไว้ที่ 
http://www.wopr.com/cgi-bin/w3t/showflat.pl?Cat=&Board=acc&Number=162389&page=3&view=expanded&sb=5&o=0&fpart= 
 
ดังนี้ 
 
Is there a way to extract data off a form that is posted in htm to Access?  
Or maybe to an Excel worksheet? I want to do this without having to copy and paste. 
 
Michael T Randolph 
 
คือเขาต้องการที่จะดึงข้อมูลจาก HTML มาใส่ Access 
 
ยังไม่มีคนตอบคำถามนี้ 
 
ผมจำได้ว่าผมเคยทดสอบโค้ดที่ Microsoft แนะนำในการ Link ข้อมูลจาก HTML ไฟล์มายัง Access ดังแสดงข้างล่าง 
 
Sub LinkHTML() 
   Dim dbs As Database 
   Dim tdfHTML As TableDef 
   Dim rstSales As Recordset 
   ' Open the Microsoft Access database. 
   Set dbs = CurrentDb 
   ' Create a TableDef object. 
   Set tdfHTML = dbs.CreateTableDef("Linked HTML Table") 
   ' Set the connection string to specify the source database type and 
   ' the full path to the file that contains the table you want to link. 
   tdfHTML.Connect = "HTML Import;" _ 
      & "DATABASE=" & ap_AppDir & "Linked Microsoft Excel Worksheet.html" 
   ' Set the SourceTableName property to the name of the table you want to access. 
   tdfHTML.SourceTableName = "Linked Microsoft Excel Worksheet" 
   ' Append the TableDef object to the TableDefs collection to create a link. 
   dbs.TableDefs.Append tdfHTML 
End Sub 
 
จากโค้ด จะต้องมีไฟล์ Linked Microsoft Excel Worksheet.html ซึ่งเก็บข้อมูลในรูปของตารางด้วย โค้ดดังกล่าวจึงจะใช้ได้ผลครับ 
 
ลองนำไปประยุกต์ใช้นะครับ

1 Reply in this Topic. Dispaly 1 pages and you are on page number 1

1 @R00439
ตามธรรมเนียม ต้องมีตัวอย่างด้วยครับ ที่ http://agserver.kku.ac.th/basiceng/myname.zip ครับ ในไฟล์นี้จะมี 2 ไฟล์ คือ myname.mdb และ myname.html ให้ลองเข้าไปดูโค้ดของ html ด้วยนะครับ แล้วจะเข้าใจภาพมากยิ่งขึ้น
@ ประกาศใช้งานเว็บบอร์ดใหม่ => บอร์ดเรียนรู้ Access สำหรับคนไทย
แล้วจะใส่ลิ้งอ้างอิงมาที่โพสต์เก่านี้หรือไม่ก็ตามสะดวกครับ
Time: 0.0565s