Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default open workbook problem

hello,
Excel 2000 sr-1 sp-3 win2000
Why this simple code what follows opens the
workbook numbering it just as if it was created
from template? 1,2, 3 and so on?
(ThisWorkbook is an add-in in my case)

this code is in fact from Rob Bovey's et al
Excel 2002 VBA programmers reference.


Sub OpenMainSheet()
Dim sFullName As String
Dim stFilename As String
Dim Wkb As Workbook

sFullName = ThisWorkbook.Path & "\Finansu_Parskatu_Formas.xls"
stFilename = GetFileName(sFullName)


If IsWorkbookOpen(stFilename) Then
Set Wkb = Workbooks(stFilename)
Wkb.Activate
Else
Set Wkb = Workbooks.Open(Filename:=sFullName)
End If
End Sub


Function IsWorkbookOpen(stName As String) As Boolean
'IsWorkbookOpen returns True if stName is a member
'of the Workbooks collection. Otherwise, it returns False
'stName must be provided as a file name without path
Dim Wkb As Workbook

On Error Resume Next
Set Wkb = Workbooks(stName)
If Not Wkb Is Nothing Then
IsWorkbookOpen = True
End If
End Function

thanks a lot
Aivars
Reply
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
How to: Open closed workbook/Search data tables/Return data to open workbook Hugh Adams Excel Discussion (Misc queries) 0 August 18th 10 02:04 PM
Axis labels problem when referenced workbook not open... InquiringMind Charts and Charting in Excel 1 October 20th 09 03:34 PM
how do i open a data workbook when i open a timesheet workbook [email protected] uk Excel Discussion (Misc queries) 2 January 4th 09 04:50 PM
excel 2003 saved file will not open without a blank workbook open Bob Excel Discussion (Misc queries) 4 November 11th 06 04:24 PM
problem saving an open excel workbook [email protected] Excel Worksheet Functions 1 August 19th 06 03:13 PM


All times are GMT +1. The time now is 04:03 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"