How to position to a specific sheet before saving

  • Thread starter Thread starter Pete Kipe
  • Start date Start date
P

Pete Kipe

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!
 
Try...

Set oSheet = oWB.Worksheets(1)
oSheet.Select
oWB.SaveAs (msExcelPath & msExcelFileName)
 
Many thanks, Jim. Works perfectly now. Pete

Jim Thomlinson said:
Try...

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top