Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Type Mismatch: array or user defined type expected | Excel Programming | |||
Type mismatch using rnge as Range with Type 8 Input Box | Excel Programming | |||
Help: Compile error: type mismatch: array or user defined type expected | Excel Programming | |||
Type Mismatch in Auto-Open Macro | Excel Programming | |||
Type Mismatch Error when getting data from another workbook | Excel Programming |