Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
open workbook problem
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 (BrianB) wrote in message om... Has the file been saved as a Template with a.xlt suffix instead of .xls ? Regards BrianB ============================================= (Aivars) wrote in message . com... 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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to: Open closed workbook/Search data tables/Return data to open workbook | Excel Discussion (Misc queries) | |||
Axis labels problem when referenced workbook not open... | Charts and Charting in Excel | |||
how do i open a data workbook when i open a timesheet workbook | Excel Discussion (Misc queries) | |||
excel 2003 saved file will not open without a blank workbook open | Excel Discussion (Misc queries) | |||
problem saving an open excel workbook | Excel Worksheet Functions |