How do you capture the name of the current worksheet in VBA?
Paul wrote:
| I'm using Automation to open and populate fields in an Excel workbook
| from Access. The code I'm using is:
|
| Function open_file_in_Excel(strFileSpec As String, intPopulate As
| Integer) Dim appExcel As Excel.Application
| Dim wbk As Excel.Workbook
| Dim wsht As Worksheet
| Set appExcel = CreateObject("Excel.Application")
| Set wbk = appExcel.Workbooks.Open(strFileSpec)
| appExcel.Visible = True
|
| At this point, I've got the workbook open, and I would like to
| capture the name of the Active Worksheet. I've tried various
| combinations like
|
| Set wsht = Workbooks(strFileSpec).ActiveSheet.name
| Set wsht = Application.Workbooks(strFileSpec).ActiveSheet
Set wsht = appExcel.Workbooks(1).ActiveSheet
or:
Set wsht = appExcel.ActiveSheet
--
KN
|