Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 17th, 2007, 01:24 PM
Authorized User
 
Join Date: Jun 2003
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to position to a specific sheet before saving

I'm creating an Excel workbook from VB6 that contains exported SQL Server data. The workbook can contain more than one sheet - when I'm ready to save it, how can I reposition to the first sheet? I've tried the following code, but when re-opening the workbook it opens to the last sheet created:

    Set oSheet = oWB.Worksheets(1)
    oWB.SaveAs (msExcelPath & msExcelFileName)

Any help would be appreciated. Thanks!
 
Old December 17th, 2007, 10:36 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

You can use either of the following

oWB.Worksheets(1).Activate

Or

 Set oSheet = oWB.Worksheets(1)
 oSheet.Activate

Cheers
Shasur

http://www.dotnetdud.blogspot.com

VBA Tips & Tricks (http://www.vbadud.blogspot.com)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy specific data from one sheet to another yogeshyl Excel VBA 2 May 11th, 2007 09:14 AM
Removing a specific sheet from a loop in Excel sibo32000 Excel VBA 1 February 9th, 2007 01:54 PM
XML, XSL:FO- saving position() mikevn123 XSLT 0 August 8th, 2006 02:51 PM
How To Export a specific Excel Sheet as a csv file mrjits Excel VBA 5 August 1st, 2006 03:04 PM
problem while saving the excel sheet icyindian Pro VB 6 3 September 20th, 2003 01:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.