# Re: VB呼叫excel巨集

Posted by Arthur on August 26, 1999 at 17:33:48:

In Reply to: Re: VB呼叫excel巨集 posted by dino on August 26, 1999 at 12:25:42:

: Option Explicit
: Dim Db As Database
: Dim Rs As Recordset

: Private Sub Form_Load()
: Set Db = OpenDatabase("xls file path", False, False, "Excel 8.0;")
: Set Rs = Db.OpenRecordset("sheet1$")
: End Sub

: 以上述方式是否无法开启marco?

: 我以OLE方式去create excel object
: 已经可以去建立chart
: class宣告大致如下:
: Private mxlApp As Excel.Application
: Private mxlBook As Excel.Workbook
: Private mxlSheet As Excel.Worksheet
: Private mxlChart As Excel.Chart
: Private mxlActive As Boolean

: Private Property Get xlApp() As Excel.Application
: If mxlApp Is Nothing Then
: Set mxlApp = GetExcelObject
: End If
: Set xlApp = mxlApp
: End Property

: Private Property Get xlBook() As Excel.Workbook
: '# prepare a workbook
: If mxlBook Is Nothing Then
: Set mxlBook = xlApp.Workbooks.Add
: End If
: Set xlBook = mxlBook
: End Property

: Private Property Get xlSheet() As Excel.Worksheet
: '# Prepare a worksheet
: If mxlSheet Is Nothing Then
: Set mxlSheet = xlBook.Worksheets(1)
: End If
: Set xlSheet = mxlSheet
: End Property

: Private Property Get xlChart() As Excel.Chart
: '# prepare a chart
: If mxlChart Is Nothing Then
: Set mxlChart = xlApp.Charts.Add
: End If
: Set xlChart = mxlChart
: End Property

: 可是一直不知marco的相关properity.
: 原理我知道,但有没有人试过?有无sample?
: 感激不尽!

A1: Yes!
A2: 我记得很久前写过, 好像是用 Run(Macro_Name, 参数1, 参数2....) 的样子!

Follow Ups:

- Re: VB呼叫excel巨集 dino 21:04:39 8/26/99 (2)
  - Re: VB呼叫excel巨集 sandy 09:32:33 8/27/99 (1)
    - Re: VB呼叫excel巨集 Arthur 10:20:48 8/27/99 (0)