Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.access.formscoding,microsoft.public.excel.programming
|
|||
|
|||
How do you capture the name of the current worksheet in VBA?
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 but none of the expressions I've tried will return the name of the Active Worksheet. Previously, I was using the literal name of the worksheet to set the Worksheet object variable wsht, but I'm trying to generalize the code so I don't have to accumulate multiple procedures for each worksheet, maintain a Select Case list, or pass the worksheet name as a parameter. What expression can I use to capture the name of the Active Worksheet in VBA? Thanks in advance, Paul |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Capture Worksheet Change Value | Excel Programming | |||
In a range of months can I capture the most current month entry? | Excel Discussion (Misc queries) | |||
Capture current WS Name? | Excel Programming | |||
Capture a worksheet in VBA | Excel Programming | |||
Capture Current Selection in a Combo Box | Excel Programming |