Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Len Len is offline
external usenet poster
 
Posts: 162
Default Open files Error in Excel 2007

Hi,

I need someone to help me to rectify the following VBA codes which had
taken from other excel file to use for Excel VBA learning exercise.
However, I face the problem when I run excel macro on these codes in
Excel 2007, it prompts the error Method Open of object Workbooks
failed and it stops at VBA code Workbooks.Open filenams (counter)

Dim lngCount As Long
Dim filenames As Variant
filenames = Application.GetOpenFilename(, , , , True)
counter = 1
While counter <= UBound(filenames)
Workbooks.Open filenames(counter)
counter = counter + 1
Wend

Thanks in advance
Regards
Len
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Open files Error in Excel 2007

Len,

From the Immediate Window pane in VBA, reply with the value for counter by
typing the following:

?counter
--
Regards,
Eddie
http://www.HelpExcel.com


"Len" wrote:

Hi,

I need someone to help me to rectify the following VBA codes which had
taken from other excel file to use for Excel VBA learning exercise.
However, I face the problem when I run excel macro on these codes in
Excel 2007, it prompts the error Method Open of object Workbooks
failed and it stops at VBA code Workbooks.Open filenams (counter)

Dim lngCount As Long
Dim filenames As Variant
filenames = Application.GetOpenFilename(, , , , True)
counter = 1
While counter <= UBound(filenames)
Workbooks.Open filenames(counter)
counter = counter + 1
Wend

Thanks in advance
Regards
Len

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Open files Error in Excel 2007

the only time i get an error is when the open file dialog is cancelled. In
that case the value of filenames is "false" and can be checked in code

otherwise code runs for me with the addition of
Dim counter As Long

in both 2003 and 2007

"HelpExcel.com" wrote in message
...
Len,

From the Immediate Window pane in VBA, reply with the value for counter by
typing the following:

?counter
--
Regards,
Eddie
http://www.HelpExcel.com


"Len" wrote:

Hi,

I need someone to help me to rectify the following VBA codes which had
taken from other excel file to use for Excel VBA learning exercise.
However, I face the problem when I run excel macro on these codes in
Excel 2007, it prompts the error Method Open of object Workbooks
failed and it stops at VBA code Workbooks.Open filenams (counter)

Dim lngCount As Long
Dim filenames As Variant
filenames = Application.GetOpenFilename(, , , , True)
counter = 1
While counter <= UBound(filenames)
Workbooks.Open filenames(counter)
counter = counter + 1
Wend

Thanks in advance
Regards
Len

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
how to open wk1 files in excel 2007 rr76012 Excel Discussion (Misc queries) 3 May 10th 23 11:42 AM
Can't open excel 2007 files from desktop MLR Excel Discussion (Misc queries) 1 September 29th 09 08:45 PM
I have Excel 2007. Some of my files open and some do not. Why? Rob Excel Discussion (Misc queries) 0 December 12th 07 03:01 PM
Excel 2007 - Can't open xls files from Explorer HappyPappy Excel Discussion (Misc queries) 10 July 17th 07 07:18 AM
Excel 2007: Files do not open JeffreyBee Excel Discussion (Misc queries) 1 February 16th 07 02:41 PM


All times are GMT +1. The time now is 11:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright 2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"