Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hello, I am new to this forum, so hello to everyone, nice to be here! I have a project that I am developing in Visual Basic 6 and part of the project requires opening, modifying and close a excel spreadsheet. I have the code and in general works fine and without problems. However one problem has arisen, when I try and open a excel spreadsheet that is in a folder that contains a space in the folder name, it won't open the spreadsheet. I have included the code below Code: -------------------- Dim oExcel As New Excel.Application Dim oWorkBook As Excel.Workbook ' before we can do anything, we need to check the excel file exists If IsFile(sExcelFile) Then ' excel file exists, proceed and open it oExcel.Workbooks.Open FileName:=sExcelFile ' do what i have to do....... oExcel.ActiveWorkbook.Save oExcel.Quit End If -------------------- I have tried to enclosed file name in quotes and that doesn't work -- 1tsols ------------------------------------------------------------------------ 1tsols's Profile: http://www.excelforum.com/member.php...o&userid=36430 View this thread: http://www.excelforum.com/showthread...hreadid=561976 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Has anyone suggestions on how to get round this -- 1tsol ----------------------------------------------------------------------- 1tsols's Profile: http://www.excelforum.com/member.php...fo&userid=3643 View this thread: http://www.excelforum.com/showthread.php?threadid=56197 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
And you're sure you're pointing to the whole path with sExcelFile????
I've never seen this when opening a file via code, but there are times that this happens when double clicking on a file in windows explorer that this happens. There are two standard suggestions to correct this... Tools|Options|General|Ignore other applications (uncheck it) --- or --- Close Excel and Windows Start Button|Run excel /unregserver then Windows Start Button|Run excel /regserver The /unregserver & /regserver stuff resets the windows registry to excel's factory defaults. ======= But man, oh, man, I be very surprised if that were your problem. I'm suspecting that sExcelFile isn't what you believe it to be. 1tsols wrote: Hello, I am new to this forum, so hello to everyone, nice to be here! I have a project that I am developing in Visual Basic 6 and part of the project requires opening, modifying and close a excel spreadsheet. I have the code and in general works fine and without problems. However one problem has arisen, when I try and open a excel spreadsheet that is in a folder that contains a space in the folder name, it won't open the spreadsheet. I have included the code below Code: -------------------- Dim oExcel As New Excel.Application Dim oWorkBook As Excel.Workbook ' before we can do anything, we need to check the excel file exists If IsFile(sExcelFile) Then ' excel file exists, proceed and open it oExcel.Workbooks.Open FileName:=sExcelFile ' do what i have to do....... oExcel.ActiveWorkbook.Save oExcel.Quit End If -------------------- I have tried to enclosed file name in quotes and that doesn't work -- 1tsols ------------------------------------------------------------------------ 1tsols's Profile: http://www.excelforum.com/member.php...o&userid=36430 View this thread: http://www.excelforum.com/showthread...hreadid=561976 -- Dave Peterson |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
What is "IsFile" ?
-- Tim Williams Palo Alto, CA "1tsols" wrote in message ... Hello, I am new to this forum, so hello to everyone, nice to be here! I have a project that I am developing in Visual Basic 6 and part of the project requires opening, modifying and close a excel spreadsheet. I have the code and in general works fine and without problems. However one problem has arisen, when I try and open a excel spreadsheet that is in a folder that contains a space in the folder name, it won't open the spreadsheet. I have included the code below Code: -------------------- Dim oExcel As New Excel.Application Dim oWorkBook As Excel.Workbook ' before we can do anything, we need to check the excel file exists If IsFile(sExcelFile) Then ' excel file exists, proceed and open it oExcel.Workbooks.Open FileName:=sExcelFile ' do what i have to do....... oExcel.ActiveWorkbook.Save oExcel.Quit End If -------------------- I have tried to enclosed file name in quotes and that doesn't work -- 1tsols ------------------------------------------------------------------------ 1tsols's Profile: http://www.excelforum.com/member.php...o&userid=36430 View this thread: http://www.excelforum.com/showthread...hreadid=561976 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Tim Williams Wrote: What is "IsFile" ? -- Tim Williams Palo Alto, CA "1tsols" wrote i message ... Hello, I am new to this forum, so hello to everyone, nice to b here! I have a project that I am developing in Visual Basic 6 and part o the project requires opening, modifying and close a excel spreadsheet. I have the code and in general works fine and without problems. However one problem has arisen, when I try and open a exce spreadsheet that is in a folder that contains a space in the folder name, i won't open the spreadsheet. I have included the code below Code: -------------------- Dim oExcel As New Excel.Application Dim oWorkBook As Excel.Workbook ' before we can do anything, we need to check the excel fil exists If IsFile(sExcelFile) Then ' excel file exists, proceed and open it oExcel.Workbooks.Open FileName:=sExcelFile ' do what i have to do....... oExcel.ActiveWorkbook.Save oExcel.Quit End If -------------------- I have tried to enclosed file name in quotes and that doesn't work -- 1tsols ------------------------------------------------------------------------ 1tsols's Profile http://www.excelforum.com/member.php...o&userid=36430 View this thread http://www.excelforum.com/showthread...hreadid=561976 IsFile() is a generic routine to check that the file exists befor attempting to open the file with excel. To Dave Williamson: I do pass the full path and filename to excel eg. "C:\Documents an Settings\JHP\My Documents\excel.xls". I will try your suggestions tomorrow when I'm back at work. Thank -- 1tsol ----------------------------------------------------------------------- 1tsols's Profile: http://www.excelforum.com/member.php...fo&userid=3643 View this thread: http://www.excelforum.com/showthread.php?threadid=56197 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
So what happens when thev file doesn't open?
Any error? Tim "1tsols" wrote in message ... IsFile() is a generic routine to check that the file exists before attempting to open the file with excel. -- 1tsols ------------------------------------------------------------------------ 1tsols's Profile: http://www.excelforum.com/member.php...o&userid=36430 View this thread: http://www.excelforum.com/showthread...hreadid=561976 |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Tim Williams Wrote: So what happens when thev file doesn't open? Any error? Tim "1tsols" wrote i message ... IsFile() is a generic routine to check that the file exists before attempting to open the file with excel. -- 1tsols ------------------------------------------------------------------------ 1tsols's Profile http://www.excelforum.com/member.php...o&userid=36430 View this thread http://www.excelforum.com/showthread...hreadid=561976 If I enclose the path & filename in quotes Excel says it can't find th file and to ensure that the file exists and the spelling is correct. If I don't enclose the path & filename in quotes Excel then splits th path & filename where there are spaces and then complains it can't fin the file(s). For example, C:\Documents and Settings\JHP\My Documents\excel.xls Without quotes I get the following messages: 'C:\Documents.xls' could not be found 'and.xls' could not be found 'Settings\JHP\My.xls' could not be found 'Documents\excel.xls' cound not be found In quotes I get: Run-time Error 1004: '"C:\Documents and Settings\JHP\M Documents\excel.xls"' can not be found. check spelling and verify th location. The unregserver / regserver commands and the "Ignore othe applications" options doesn't solve this. Hope this helps -- 1tsol ----------------------------------------------------------------------- 1tsols's Profile: http://www.excelforum.com/member.php...fo&userid=3643 View this thread: http://www.excelforum.com/showthread.php?threadid=56197 |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This works fine, so spaces in the file path is not your problem:
Dim strTemp As String strTemp = "C:\Documents and Settings\Nick\Desktop\Book5.xls" Workbooks.Open (strTemp) Is this on an English language OS ? NickHK "1tsols" wrote in message ... Tim Williams Wrote: So what happens when thev file doesn't open? Any error? Tim "1tsols" wrote in message ... IsFile() is a generic routine to check that the file exists before attempting to open the file with excel. -- 1tsols ------------------------------------------------------------------------ 1tsols's Profile: http://www.excelforum.com/member.php...o&userid=36430 View this thread: http://www.excelforum.com/showthread...hreadid=561976 If I enclose the path & filename in quotes Excel says it can't find the file and to ensure that the file exists and the spelling is correct. If I don't enclose the path & filename in quotes Excel then splits the path & filename where there are spaces and then complains it can't find the file(s). For example, C:\Documents and Settings\JHP\My Documents\excel.xls Without quotes I get the following messages: 'C:\Documents.xls' could not be found 'and.xls' could not be found 'Settings\JHP\My.xls' could not be found 'Documents\excel.xls' cound not be found In quotes I get: Run-time Error 1004: '"C:\Documents and Settings\JHP\My Documents\excel.xls"' can not be found. check spelling and verify the location. The unregserver / regserver commands and the "Ignore other applications" options doesn't solve this. Hope this helps. -- 1tsols ------------------------------------------------------------------------ 1tsols's Profile: http://www.excelforum.com/member.php...o&userid=36430 View this thread: http://www.excelforum.com/showthread...hreadid=561976 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Pulling pdf files from general folder to specific folder | Excel Discussion (Misc queries) | |||
How to decide folder-depth or How to select more folders/subfolders (folder-tree) ? | Excel Discussion (Misc queries) | |||
how can I specific a folder with wildcard criteria and excel will import all the correct files in that folder? | Excel Discussion (Misc queries) | |||
how can I specific a folder with wildcard criteria and excel will import all the correct files in that folder? | Excel Programming | |||
open file from folder save in new folder | Excel Programming |