type mismatch, can't open a workbook?
i can't get this workbook to open. The folder, and filename is constant.
Thanks, Public Sub openFile() Const fName As String = "Book1.xls" Const fPath As String = "MacOS X:SSP Folder:" Dim wkb As Workbook Set wkb = fPath & fName wkb.Open End Sub |
type mismatch, can't open a workbook?
How about:
Public Sub openFile() Const fName As String = "Book1.xls" Const fPath As String = "MacOS X:SSP Folder:" Dim wkb As Workbook Set wkb = workbooks.open(filename:=fPath & fName) end sub Janis wrote: i can't get this workbook to open. The folder, and filename is constant. Thanks, Public Sub openFile() Const fName As String = "Book1.xls" Const fPath As String = "MacOS X:SSP Folder:" Dim wkb As Workbook Set wkb = fPath & fName wkb.Open End Sub -- Dave Peterson |
type mismatch, can't open a workbook?
Thank-you
"Janis" wrote: i can't get this workbook to open. The folder, and filename is constant. Thanks, Public Sub openFile() Const fName As String = "Book1.xls" Const fPath As String = "MacOS X:SSP Folder:" Dim wkb As Workbook Set wkb = fPath & fName wkb.Open End Sub |
type mismatch, can't open a workbook?
I don't know why you can't just open a workbook why do you have to set it to
an object? Is it because it is the open object? It is a little weird to think like that. "Dave Peterson" wrote: How about: Public Sub openFile() Const fName As String = "Book1.xls" Const fPath As String = "MacOS X:SSP Folder:" Dim wkb As Workbook Set wkb = workbooks.open(filename:=fPath & fName) end sub Janis wrote: i can't get this workbook to open. The folder, and filename is constant. Thanks, Public Sub openFile() Const fName As String = "Book1.xls" Const fPath As String = "MacOS X:SSP Folder:" Dim wkb As Workbook Set wkb = fPath & fName wkb.Open End Sub -- Dave Peterson |
type mismatch, can't open a workbook?
From the looks of your existing code, it looked like you wanted a reference to
that newly opened workbook. But you don't need to: Public Sub openFile() Const fName As String = "Book1.xls" Const fPath As String = "MacOS X:SSP Folder:" workbooks.open filename:=fPath & fName end sub But by using an object variable, it'll make it easier to do things later in the code--but only if you need to! Janis wrote: I don't know why you can't just open a workbook why do you have to set it to an object? Is it because it is the open object? It is a little weird to think like that. "Dave Peterson" wrote: How about: Public Sub openFile() Const fName As String = "Book1.xls" Const fPath As String = "MacOS X:SSP Folder:" Dim wkb As Workbook Set wkb = workbooks.open(filename:=fPath & fName) end sub Janis wrote: i can't get this workbook to open. The folder, and filename is constant. Thanks, Public Sub openFile() Const fName As String = "Book1.xls" Const fPath As String = "MacOS X:SSP Folder:" Dim wkb As Workbook Set wkb = fPath & fName wkb.Open End Sub -- Dave Peterson -- Dave Peterson |
All times are GMT +1. The time now is 07:10 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com