LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.vb.general.discussion
external usenet poster
 
Posts: 97
Default How to improve my code?

My app checks for the (specified) opened Excel spreadsheet and if it is not
opened tries to open it.
Everything works fine if that is a single worksheet.
However, if the xls file contains several sheets (workbooks?) my method
fails miserably.
Below is the code:
XLSheetFullTitle --- full path to the .xls file
ExSheetTitle --- sheet's title (excluding path)
If FileExists(XLSheetFullTitle) = True Then
If moExcelApp.Workbooks.Count 0 Then 'checking if specified
sheet is opened already
For i = 1 To moExcelApp.Worksheets.Count
If moExcelApp.Worksheets(i).Name = Left(ExSheetTitle,
Len(ExSheetTitle) - 4) Then j = 77: Exit For
Next
End If
If j < 77 Then Set moExcelWS =
CreateObject(moExcelApp.Workbooks.Open(XLSheetFull Title)) 'loads (with
error) spreadsheet
If moExcelWS Is Nothing Then Set moExcelWS =
moExcelApp.Workbooks(ExSheetTitle).Worksheets(Left (ExSheetTitle,
Len(ExSheetTitle) - 4))

Your comments appreciated,
Jack


 
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
Improve code rjamison Excel Programming 0 June 14th 05 12:14 AM
Improve code rjamison Excel Programming 0 June 14th 05 12:14 AM
Improve code rjamison Excel Programming 0 June 14th 05 12:14 AM
Improve code Gareth Excel Programming 5 April 20th 05 03:41 PM
How to improve this code? alainB[_21_] Excel Programming 4 May 22nd 04 11:20 AM


All times are GMT +1. The time now is 07:09 AM.

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

About Us

"It's about Microsoft Excel"