open workbook problem

A

Aivars

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
 
B

BrianB

Has the file been saved as a Template with a.xlt suffix instead of .xls ?

Regards
BrianB
=============================================
 
A

Aivars

yes,
it was .xlt file before, now i have saved it with .xls extention
and i am opening .xls file.
could there be a problem?
aivars
 

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

Top