![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Hi all,
I'm using the code below to open a work book and move to a particular worksheet in the work book. The problem arises in the Else Clause of the IF Then statement. I'm not sure how to set Excel to a particular sheet in the workbook, even though I have both the name of the sheet and the number of the sheet. The work books can have either 1 or 2 worksheets in them. If it is 1 sheet, there is no problem. If there the workbook has 2 sheets I want to set the 2nd sheet as the active sheet. Any help is appreciated. Thanks Craig Public Function OpenWorkbook(strFilename) As String ' Comments : Open an Excel workbook and returns the FSR Type. ' Parameters: DocumentName - Path and file name to open ' Returns : FSR Type (Old or New) ' Dim strFSRType As String Dim xlActiveSheet As Excel.Worksheet On Error GoTo PROC_ERR Set m_Excel = CreateObject("EXCEL.APPLICATION") Set m_Workbook = m_Excel.Workbooks.Open(strFilename) Set xlActiveSheet = m_Workbook.ActiveSheet If xlActiveSheet.Name = "main" Then 'ActiveWorkbook.Sheets.Count OpenWorkbook = "Old" Else OpenWorkbook = "New" xlActiveSheet = m_Workbook.Sheets("FSR - 45043 Report Sheet") End If PROC_EXIT: Exit Function PROC_ERR: MsgBox "Error: " & Err.Number & ". " & Err.Description Resume PROC_EXIT End Function |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
shortcut in excel sheet to and Outlook email | Finny | Outlook - General Queries | 2 | September 29th 06 04:00 PM |
How do I Autopopulate an Outlook form from an Excel Sheet? | AttyBhai | Outlook - Using Forms | 1 | September 19th 06 01:18 PM |
Send email to email addressess in Excel Sheet | Darrell | Outlook - Using Contacts | 2 | September 18th 06 12:20 PM |
Setting in OE tools dosen't work | Jack Nation | Outlook Express | 6 | August 15th 06 06:50 AM |
How can I extract share calender information to excel sheet | TILLYCHIPS | Outlook - Calandaring | 1 | April 17th 06 03:37 PM |