Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 360
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
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
Type Mismatch: array or user defined type expected ExcelMonkey Excel Programming 4 July 6th 06 03:40 PM
Type mismatch using rnge as Range with Type 8 Input Box STEVE BELL Excel Programming 11 December 3rd 05 05:02 AM
Help: Compile error: type mismatch: array or user defined type expected lvcha.gouqizi Excel Programming 1 October 31st 05 08:20 PM
Type Mismatch in Auto-Open Macro Carl Bowman Excel Programming 3 February 16th 05 12:59 AM
Type Mismatch Error when getting data from another workbook Tony Zappal Excel Programming 2 January 12th 05 10:29 PM


All times are GMT +1. The time now is 09:42 PM.

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"