LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA application; Subscript Out of Range

If you activeworkbook is also in C:\ as you seem to indicate, then the
string you build for filepath will be

"C:\\filename.xls"

since the Activeworkbook.Path for a file in the root directory includes the
"\" on the end.

filePath = Activeworkbook.Path
if left(filePath,1) < "\" then filePath = filepath & "\"
filePath = filepath & filename & ".xls"

NT based systems don't seem to be bothered by the \\ (from what I have
seen), but windows 9.x will break.

--
Regards,
Tom Ogilvy


"M J" wrote in message
...
Hi

My problem occurs when I click a button to open another
excel file from a macro within a separate excel file. I
think the code and error occurs simply from the following
lines of code:

On Error GoTo ErrorHandler:
filepath = ActiveWorkbook.Path & "\" & filename & ".xls"
oApp1.Workbooks.Open filepath

I am not using any network mappings to find the files. In
fact, I saved all the files on the local C:\ on my
coworkers computer.

When I click the button, I get a "Subscript out of Range"
error and for some reason, the excel file I'm tryin to
open gets locked for editing.

??


-----Original Message-----
It is unlikely that your problem is the version of

VBA/Excel your
coworker is using. The most likely explanation based on

what I know so
far, which isn't much, is that the file your code is

opening is on your
network and the network drive where it is located is

mapped differently
on your coworker's computer. Check that out and let me

know how that
works out. - Pikus


---
Message posted from http://www.ExcelForum.com/

.



 
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
Subscript out of Range Steve Excel Discussion (Misc queries) 3 April 15th 09 04:01 PM
what does 'Subscript Out of range' mean?? Gary Excel Worksheet Functions 2 March 22nd 07 01:33 AM
9: Subscript out of range jenz21985 Excel Discussion (Misc queries) 6 May 5th 06 03:36 PM
SubScript Out Of Range. Sam Excel Programming 4 December 21st 03 02:10 AM
Subscript Out of Range John Wilson Excel Programming 2 September 7th 03 04:07 AM


All times are GMT +1. The time now is 08:22 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"