# Re: 关于建立资料库问题

Posted by 小琳 on August 29, 1999 at 14:36:17:

In Reply to: Re: 关于建立资料库问题 posted by 小琳 on August 28, 1999 at 14:39:30:

: : 请问如何建立一个Excel格式的资料库, 并设定资料表sheet1
: : 的第一个栏位caption为"Name", 弟二栏位为"Address"??
: : Thank you!

: :::小女子看不太懂您的问题，是否建立资料库还是利用VB
: 程式来建立一个Excel的Sheet1!!! 小薰

:::程式如下：
Option Explicit

Private Sub Command1_Click()
Dim temp As Excel.Application
Dim i As Integer
Data1.Recordset.MoveLast
i = Data1.Recordset.RecordCount
Set temp = CreateObject("excel.application")
With temp
.Visible = True
.Workbooks.Add
.Range("a1") = "name"
.Range("b1") = "address"
Data1.Recordset.MoveFirst
For i = 1 To i
.Range("a" & i + 1) = Data1.Recordset(0)
.Range("b" & i + 1) = Data1.Recordset(1)
Data1.Recordset.MoveNext
Next i
.Workbooks(1).SaveAs (储存档名）
.Quit
End With
Set temp = Nothing
End Sub

Follow Ups: