LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.access.formscoding,microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Capture Worksheet Change Value Risky Dave Excel Programming 1 January 6th 09 06:43 PM
In a range of months can I capture the most current month entry? Karlene Excel Discussion (Misc queries) 4 August 15th 07 05:55 PM
Capture current WS Name? Dave Birley Excel Programming 5 May 8th 07 05:09 PM
Capture a worksheet in VBA Madiya Excel Programming 6 August 11th 06 03:40 PM
Capture Current Selection in a Combo Box Randy[_10_] Excel Programming 3 August 6th 04 09:43 PM


All times are GMT +1. The time now is 04:32 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"