Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default Spaces in folder name and file name

I'm defining a constant that will access a file. I've been testing it with
the following constant:

Const cstrDatabaseWB As String = "C:\Documents and Settings\5YPJB\My
Documents\Excel documents\Sherry project\real1.xls"

That works fine. Now I'm working with the real file, named by someone else,
and I've got the constant defined as

Const cstrDatabaseWB As String = "G:\WI\ACS\ACS QA\FY10 CQRS and Local
Reviews (version 1).xls"

There is a space in the folder name "ACS AQ" and multiple spaces in the
filename. I'm getting a Run time Error 1004 Application/Object Defined Error
when the code tries to execute the following line:

Application.Workbooks.Open (cstrDatabaseWB)

I tried using single quotes inside the double quotes around the file name
but that didn't help. How do I need to modify this code to open this file?

Any help will be greatly appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Spaces in folder name and file name

The code isn't the problem.

You've got a mismatch between your spelling of the drive/path/filename in your
code and the actual name of the file.

Merlynsdad wrote:

I'm defining a constant that will access a file. I've been testing it with
the following constant:

Const cstrDatabaseWB As String = "C:\Documents and Settings\5YPJB\My
Documents\Excel documents\Sherry project\real1.xls"

That works fine. Now I'm working with the real file, named by someone else,
and I've got the constant defined as

Const cstrDatabaseWB As String = "G:\WI\ACS\ACS QA\FY10 CQRS and Local
Reviews (version 1).xls"

There is a space in the folder name "ACS AQ" and multiple spaces in the
filename. I'm getting a Run time Error 1004 Application/Object Defined Error
when the code tries to execute the following line:

Application.Workbooks.Open (cstrDatabaseWB)

I tried using single quotes inside the double quotes around the file name
but that didn't help. How do I need to modify this code to open this file?

Any help will be greatly appreciated.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Spaces in folder name and file name

I wonder if there is an additional space (or something) that you are not
seeing in the path and filename.

Using the workbook with your code, in VBA open the immediate window (menu
item View-Immediate Window or Ctrl + G)

Open the required workbook and ensure that it is the active workbook.

Select the VBA window and in the Immediate Window insert the following and
then press Enter.

Debug.Print ActiveWorkbook.Path & "\" & ActiveWorkbook.Name

Copy the returned result and paste it into your code between the double
quotes in lieu of the path and name you have used.

--
Regards,

OssieMac


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Spaces in folder name and file name

Just to save you some checking.

Open that file manually.

Then make sure it's the activeworkbook.
Open the VBE (alt-f11 is one way)
show the immediate window (ctrl-g)
and type this:
?activeworkbook.fullname
(and hit enter)

You'll be able to copy|paste from that immediate window into your code.



Merlynsdad wrote:

I'm defining a constant that will access a file. I've been testing it with
the following constant:

Const cstrDatabaseWB As String = "C:\Documents and Settings\5YPJB\My
Documents\Excel documents\Sherry project\real1.xls"

That works fine. Now I'm working with the real file, named by someone else,
and I've got the constant defined as

Const cstrDatabaseWB As String = "G:\WI\ACS\ACS QA\FY10 CQRS and Local
Reviews (version 1).xls"

There is a space in the folder name "ACS AQ" and multiple spaces in the
filename. I'm getting a Run time Error 1004 Application/Object Defined Error
when the code tries to execute the following line:

Application.Workbooks.Open (cstrDatabaseWB)

I tried using single quotes inside the double quotes around the file name
but that didn't help. How do I need to modify this code to open this file?

Any help will be greatly appreciated.


--

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
Check for file in folder, if not there, open folder to rename file Don M. Excel Programming 9 October 22nd 08 07:34 PM
Save file in a new folder, but create folder only if folder doesn't already exist? nbaj2k[_40_] Excel Programming 6 August 11th 06 08:41 PM
Help: Can open a spreadsheet in a folder which contains spaces in the folder name! 1tsols Excel Programming 17 July 31st 06 04:26 PM
Need code to save file to new folder, erase from old folder Ron M. Excel Discussion (Misc queries) 1 February 24th 06 06:02 PM
Create Folder and Text File in folder Todd Huttentsine Excel Programming 2 April 29th 04 03:41 PM


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