Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Excel XP & Win XP
I'm helping an OP with a project. The code loops through all the files in a folder, opens each, does things, closes the file and opens the next file, etc. The code is placed in the Personal.xls file. It works fine for me. It fails on opening the first file for him (will not open the file). An error is produced saying that opening the file failed. He has Excel 2003. He sent me his Personal.xls file. I changed the name and put it in my XLSTART folder. It works fine with my path. I created his path on my computer and that works fine too. I checked the VBE - Tools - References. The only thing I have checked that he doesn't is "Microsoft Forms 2.0 Object Library". He doesn't have anything like that to check. Does anyone have any ideas of what I could do? Thanks for your time. Otto |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It is suspicious that opening is the problem.
Make sure that the Security settings for Excel are the same on both machines. -- Gary's Student "Otto Moehrbach" wrote: Excel XP & Win XP I'm helping an OP with a project. The code loops through all the files in a folder, opens each, does things, closes the file and opens the next file, etc. The code is placed in the Personal.xls file. It works fine for me. It fails on opening the first file for him (will not open the file). An error is produced saying that opening the file failed. He has Excel 2003. He sent me his Personal.xls file. I changed the name and put it in my XLSTART folder. It works fine with my path. I created his path on my computer and that works fine too. I checked the VBE - Tools - References. The only thing I have checked that he doesn't is "Microsoft Forms 2.0 Object Library". He doesn't have anything like that to check. Does anyone have any ideas of what I could do? Thanks for your time. Otto |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Do you know the exact wording of the error message? Is it coming from Excel
or from VBA? he doesn't is "Microsoft Forms 2.0 Object Library". He doesn't have anything like that to check. That's a big clue. Does he really not have the Forms library listed in the References list box? Even if it not checked, it should be present in the list. MSFORMS is part of the basic Excel installation, not optional in any way. If "Microsoft Forms 2.0 Object Library" doesn't appear at all in the References list, the basic installation of Excel is bad. The first thing I'd advise to your user is to unregister and re-register Excel. Close Excel (and all other Office programs), go to the Windows Start menu, choose Run and enter RegSvr32 "Excel.exe" /unregserver The repeat the process with RegSvr32 "Excel.exe" /regserver You may have to use the full file path of Excel instead of just "Excel.exe". In the Immediate window of VBA, enter the following and press Enter. ?Application.Path & "\Excel.exe" This will display the full pathname of Excel.exe. Use that filename in place of "Excel.exe" in the RegSvr32 commands. Now try to open the workbook. In VBA, ensure that "Microsoft Forms 2.0 Object Library" appears in the list of references. Try adding a UserForm to the project. Doing so will automatically add a reference to MSFORMS. If this fails, and you (by which I mean your user) get an error message when trying to add a UserForm, try to add the reference to MSFORMS manually. In the References dialog, click "Browse" and navigate to the file C:\WINDOWS\system32\FM20.DLL If you find the file, click OK or Open. If you don't find the file, then you'll probably want to run "Detect And Repair" from the Help menu. If this doesn't fix the problem, you'll likely need to uninstall and reinstall Office. A missing MSFORMS reference item and/or a missing FM20.DLL file indicates that something serious has gone on. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "Otto Moehrbach" wrote in message ... Excel XP & Win XP I'm helping an OP with a project. The code loops through all the files in a folder, opens each, does things, closes the file and opens the next file, etc. The code is placed in the Personal.xls file. It works fine for me. It fails on opening the first file for him (will not open the file). An error is produced saying that opening the file failed. He has Excel 2003. He sent me his Personal.xls file. I changed the name and put it in my XLSTART folder. It works fine with my path. I created his path on my computer and that works fine too. I checked the VBE - Tools - References. The only thing I have checked that he doesn't is "Microsoft Forms 2.0 Object Library". He doesn't have anything like that to check. Does anyone have any ideas of what I could do? Thanks for your time. Otto |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You might ask if the OP is able to use controls from the control toolbox
toolbar in Excel. If he can, then he might not be giving you correct information on the Microsoft Forms 2.0 Object library being available to select. -- Regards, Tom Ogilvy "Chip Pearson" wrote in message ... Do you know the exact wording of the error message? Is it coming from Excel or from VBA? he doesn't is "Microsoft Forms 2.0 Object Library". He doesn't have anything like that to check. That's a big clue. Does he really not have the Forms library listed in the References list box? Even if it not checked, it should be present in the list. MSFORMS is part of the basic Excel installation, not optional in any way. If "Microsoft Forms 2.0 Object Library" doesn't appear at all in the References list, the basic installation of Excel is bad. The first thing I'd advise to your user is to unregister and re-register Excel. Close Excel (and all other Office programs), go to the Windows Start menu, choose Run and enter RegSvr32 "Excel.exe" /unregserver The repeat the process with RegSvr32 "Excel.exe" /regserver You may have to use the full file path of Excel instead of just "Excel.exe". In the Immediate window of VBA, enter the following and press Enter. ?Application.Path & "\Excel.exe" This will display the full pathname of Excel.exe. Use that filename in place of "Excel.exe" in the RegSvr32 commands. Now try to open the workbook. In VBA, ensure that "Microsoft Forms 2.0 Object Library" appears in the list of references. Try adding a UserForm to the project. Doing so will automatically add a reference to MSFORMS. If this fails, and you (by which I mean your user) get an error message when trying to add a UserForm, try to add the reference to MSFORMS manually. In the References dialog, click "Browse" and navigate to the file C:\WINDOWS\system32\FM20.DLL If you find the file, click OK or Open. If you don't find the file, then you'll probably want to run "Detect And Repair" from the Help menu. If this doesn't fix the problem, you'll likely need to uninstall and reinstall Office. A missing MSFORMS reference item and/or a missing FM20.DLL file indicates that something serious has gone on. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "Otto Moehrbach" wrote in message ... Excel XP & Win XP I'm helping an OP with a project. The code loops through all the files in a folder, opens each, does things, closes the file and opens the next file, etc. The code is placed in the Personal.xls file. It works fine for me. It fails on opening the first file for him (will not open the file). An error is produced saying that opening the file failed. He has Excel 2003. He sent me his Personal.xls file. I changed the name and put it in my XLSTART folder. It works fine with my path. I created his path on my computer and that works fine too. I checked the VBE - Tools - References. The only thing I have checked that he doesn't is "Microsoft Forms 2.0 Object Library". He doesn't have anything like that to check. Does anyone have any ideas of what I could do? Thanks for your time. Otto |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi, I've got the problem that Otto is helping me with. I've done a complete
detect and repair and as Chip has suggested I've looked in the References List box and I do have Microsoft Forms 2.0 Object Library installed and checked. I also have the FM20.dll installed and visible. I also attempted to include a user form and it was installed without a hitch, absolutely no problem. I did send the file to Otto and he can't recreate the problem. The code performs as it should on his machine and completes. I still get the error and the code stops, as Otto has said. Is there anything that anyone can think of that I can do that he and I haven't. If uninstalling and reinstalling Excel would work I could do that also. Thanks Bob Reynolds "Chip Pearson" wrote in message ... Do you know the exact wording of the error message? Is it coming from Excel or from VBA? he doesn't is "Microsoft Forms 2.0 Object Library". He doesn't have anything like that to check. That's a big clue. Does he really not have the Forms library listed in the References list box? Even if it not checked, it should be present in the list. MSFORMS is part of the basic Excel installation, not optional in any way. If "Microsoft Forms 2.0 Object Library" doesn't appear at all in the References list, the basic installation of Excel is bad. The first thing I'd advise to your user is to unregister and re-register Excel. Close Excel (and all other Office programs), go to the Windows Start menu, choose Run and enter RegSvr32 "Excel.exe" /unregserver The repeat the process with RegSvr32 "Excel.exe" /regserver You may have to use the full file path of Excel instead of just "Excel.exe". In the Immediate window of VBA, enter the following and press Enter. ?Application.Path & "\Excel.exe" This will display the full pathname of Excel.exe. Use that filename in place of "Excel.exe" in the RegSvr32 commands. Now try to open the workbook. In VBA, ensure that "Microsoft Forms 2.0 Object Library" appears in the list of references. Try adding a UserForm to the project. Doing so will automatically add a reference to MSFORMS. If this fails, and you (by which I mean your user) get an error message when trying to add a UserForm, try to add the reference to MSFORMS manually. In the References dialog, click "Browse" and navigate to the file C:\WINDOWS\system32\FM20.DLL If you find the file, click OK or Open. If you don't find the file, then you'll probably want to run "Detect And Repair" from the Help menu. If this doesn't fix the problem, you'll likely need to uninstall and reinstall Office. A missing MSFORMS reference item and/or a missing FM20.DLL file indicates that something serious has gone on. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "Otto Moehrbach" wrote in message ... Excel XP & Win XP I'm helping an OP with a project. The code loops through all the files in a folder, opens each, does things, closes the file and opens the next file, etc. The code is placed in the Personal.xls file. It works fine for me. It fails on opening the first file for him (will not open the file). An error is produced saying that opening the file failed. He has Excel 2003. He sent me his Personal.xls file. I changed the name and put it in my XLSTART folder. It works fine with my path. I created his path on my computer and that works fine too. I checked the VBE - Tools - References. The only thing I have checked that he doesn't is "Microsoft Forms 2.0 Object Library". He doesn't have anything like that to check. Does anyone have any ideas of what I could do? Thanks for your time. Otto |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
What's the error that is displayed?
Any chance that Otto has access to that folder and you don't? Can you open the file just via File|Open? rjr wrote: Hi, I've got the problem that Otto is helping me with. I've done a complete detect and repair and as Chip has suggested I've looked in the References List box and I do have Microsoft Forms 2.0 Object Library installed and checked. I also have the FM20.dll installed and visible. I also attempted to include a user form and it was installed without a hitch, absolutely no problem. I did send the file to Otto and he can't recreate the problem. The code performs as it should on his machine and completes. I still get the error and the code stops, as Otto has said. Is there anything that anyone can think of that I can do that he and I haven't. If uninstalling and reinstalling Excel would work I could do that also. Thanks Bob Reynolds "Chip Pearson" wrote in message ... Do you know the exact wording of the error message? Is it coming from Excel or from VBA? he doesn't is "Microsoft Forms 2.0 Object Library". He doesn't have anything like that to check. That's a big clue. Does he really not have the Forms library listed in the References list box? Even if it not checked, it should be present in the list. MSFORMS is part of the basic Excel installation, not optional in any way. If "Microsoft Forms 2.0 Object Library" doesn't appear at all in the References list, the basic installation of Excel is bad. The first thing I'd advise to your user is to unregister and re-register Excel. Close Excel (and all other Office programs), go to the Windows Start menu, choose Run and enter RegSvr32 "Excel.exe" /unregserver The repeat the process with RegSvr32 "Excel.exe" /regserver You may have to use the full file path of Excel instead of just "Excel.exe". In the Immediate window of VBA, enter the following and press Enter. ?Application.Path & "\Excel.exe" This will display the full pathname of Excel.exe. Use that filename in place of "Excel.exe" in the RegSvr32 commands. Now try to open the workbook. In VBA, ensure that "Microsoft Forms 2.0 Object Library" appears in the list of references. Try adding a UserForm to the project. Doing so will automatically add a reference to MSFORMS. If this fails, and you (by which I mean your user) get an error message when trying to add a UserForm, try to add the reference to MSFORMS manually. In the References dialog, click "Browse" and navigate to the file C:\WINDOWS\system32\FM20.DLL If you find the file, click OK or Open. If you don't find the file, then you'll probably want to run "Detect And Repair" from the Help menu. If this doesn't fix the problem, you'll likely need to uninstall and reinstall Office. A missing MSFORMS reference item and/or a missing FM20.DLL file indicates that something serious has gone on. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "Otto Moehrbach" wrote in message ... Excel XP & Win XP I'm helping an OP with a project. The code loops through all the files in a folder, opens each, does things, closes the file and opens the next file, etc. The code is placed in the Personal.xls file. It works fine for me. It fails on opening the first file for him (will not open the file). An error is produced saying that opening the file failed. He has Excel 2003. He sent me his Personal.xls file. I changed the name and put it in my XLSTART folder. It works fine with my path. I created his path on my computer and that works fine too. I checked the VBE - Tools - References. The only thing I have checked that he doesn't is "Microsoft Forms 2.0 Object Library". He doesn't have anything like that to check. Does anyone have any ideas of what I could do? Thanks for your time. Otto -- Dave Peterson |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Run Time Error 1004 Method OPEN of object.workbooks failed. This is in
the Microsoft vb alert window. the Error place in the code is at Do While TheFile < "" If TheFile < "Daily Error report MASTER.xls" Then MsgBox TheFile Set wb = Workbooks.Open(ThePath & "\" & TheFile) << error line. I've sent Otto the files while he was working on the code. The code works perfectly for him at his computer. I can open ALL files from file open or double clicking on the file. "Dave Peterson" wrote in message ... What's the error that is displayed? Any chance that Otto has access to that folder and you don't? Can you open the file just via File|Open? rjr wrote: Hi, I've got the problem that Otto is helping me with. I've done a complete detect and repair and as Chip has suggested I've looked in the References List box and I do have Microsoft Forms 2.0 Object Library installed and checked. I also have the FM20.dll installed and visible. I also attempted to include a user form and it was installed without a hitch, absolutely no problem. I did send the file to Otto and he can't recreate the problem. The code performs as it should on his machine and completes. I still get the error and the code stops, as Otto has said. Is there anything that anyone can think of that I can do that he and I haven't. If uninstalling and reinstalling Excel would work I could do that also. Thanks Bob Reynolds "Chip Pearson" wrote in message ... Do you know the exact wording of the error message? Is it coming from Excel or from VBA? he doesn't is "Microsoft Forms 2.0 Object Library". He doesn't have anything like that to check. That's a big clue. Does he really not have the Forms library listed in the References list box? Even if it not checked, it should be present in the list. MSFORMS is part of the basic Excel installation, not optional in any way. If "Microsoft Forms 2.0 Object Library" doesn't appear at all in the References list, the basic installation of Excel is bad. The first thing I'd advise to your user is to unregister and re-register Excel. Close Excel (and all other Office programs), go to the Windows Start menu, choose Run and enter RegSvr32 "Excel.exe" /unregserver The repeat the process with RegSvr32 "Excel.exe" /regserver You may have to use the full file path of Excel instead of just "Excel.exe". In the Immediate window of VBA, enter the following and press Enter. ?Application.Path & "\Excel.exe" This will display the full pathname of Excel.exe. Use that filename in place of "Excel.exe" in the RegSvr32 commands. Now try to open the workbook. In VBA, ensure that "Microsoft Forms 2.0 Object Library" appears in the list of references. Try adding a UserForm to the project. Doing so will automatically add a reference to MSFORMS. If this fails, and you (by which I mean your user) get an error message when trying to add a UserForm, try to add the reference to MSFORMS manually. In the References dialog, click "Browse" and navigate to the file C:\WINDOWS\system32\FM20.DLL If you find the file, click OK or Open. If you don't find the file, then you'll probably want to run "Detect And Repair" from the Help menu. If this doesn't fix the problem, you'll likely need to uninstall and reinstall Office. A missing MSFORMS reference item and/or a missing FM20.DLL file indicates that something serious has gone on. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "Otto Moehrbach" wrote in message ... Excel XP & Win XP I'm helping an OP with a project. The code loops through all the files in a folder, opens each, does things, closes the file and opens the next file, etc. The code is placed in the Personal.xls file. It works fine for me. It fails on opening the first file for him (will not open the file). An error is produced saying that opening the file failed. He has Excel 2003. He sent me his Personal.xls file. I changed the name and put it in my XLSTART folder. It works fine with my path. I created his path on my computer and that works fine too. I checked the VBE - Tools - References. The only thing I have checked that he doesn't is "Microsoft Forms 2.0 Object Library". He doesn't have anything like that to check. Does anyone have any ideas of what I could do? Thanks for your time. Otto -- Dave Peterson |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
What do you see in the msgbox right before it fails?
Do you see "daily error report master.xls"? If you do, then I'm guessing that the code that you're running is in a file with that name. Maybe this would help: If lcase(TheFile) < lcase("Daily Error report MASTER.xls") Then (or maybe not!) rjr wrote: Run Time Error 1004 Method OPEN of object.workbooks failed. This is in the Microsoft vb alert window. the Error place in the code is at Do While TheFile < "" If TheFile < "Daily Error report MASTER.xls" Then MsgBox TheFile Set wb = Workbooks.Open(ThePath & "\" & TheFile) << error line. I've sent Otto the files while he was working on the code. The code works perfectly for him at his computer. I can open ALL files from file open or double clicking on the file. "Dave Peterson" wrote in message ... What's the error that is displayed? Any chance that Otto has access to that folder and you don't? Can you open the file just via File|Open? rjr wrote: Hi, I've got the problem that Otto is helping me with. I've done a complete detect and repair and as Chip has suggested I've looked in the References List box and I do have Microsoft Forms 2.0 Object Library installed and checked. I also have the FM20.dll installed and visible. I also attempted to include a user form and it was installed without a hitch, absolutely no problem. I did send the file to Otto and he can't recreate the problem. The code performs as it should on his machine and completes. I still get the error and the code stops, as Otto has said. Is there anything that anyone can think of that I can do that he and I haven't. If uninstalling and reinstalling Excel would work I could do that also. Thanks Bob Reynolds "Chip Pearson" wrote in message ... Do you know the exact wording of the error message? Is it coming from Excel or from VBA? he doesn't is "Microsoft Forms 2.0 Object Library". He doesn't have anything like that to check. That's a big clue. Does he really not have the Forms library listed in the References list box? Even if it not checked, it should be present in the list. MSFORMS is part of the basic Excel installation, not optional in any way. If "Microsoft Forms 2.0 Object Library" doesn't appear at all in the References list, the basic installation of Excel is bad. The first thing I'd advise to your user is to unregister and re-register Excel. Close Excel (and all other Office programs), go to the Windows Start menu, choose Run and enter RegSvr32 "Excel.exe" /unregserver The repeat the process with RegSvr32 "Excel.exe" /regserver You may have to use the full file path of Excel instead of just "Excel.exe". In the Immediate window of VBA, enter the following and press Enter. ?Application.Path & "\Excel.exe" This will display the full pathname of Excel.exe. Use that filename in place of "Excel.exe" in the RegSvr32 commands. Now try to open the workbook. In VBA, ensure that "Microsoft Forms 2.0 Object Library" appears in the list of references. Try adding a UserForm to the project. Doing so will automatically add a reference to MSFORMS. If this fails, and you (by which I mean your user) get an error message when trying to add a UserForm, try to add the reference to MSFORMS manually. In the References dialog, click "Browse" and navigate to the file C:\WINDOWS\system32\FM20.DLL If you find the file, click OK or Open. If you don't find the file, then you'll probably want to run "Detect And Repair" from the Help menu. If this doesn't fix the problem, you'll likely need to uninstall and reinstall Office. A missing MSFORMS reference item and/or a missing FM20.DLL file indicates that something serious has gone on. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "Otto Moehrbach" wrote in message ... Excel XP & Win XP I'm helping an OP with a project. The code loops through all the files in a folder, opens each, does things, closes the file and opens the next file, etc. The code is placed in the Personal.xls file. It works fine for me. It fails on opening the first file for him (will not open the file). An error is produced saying that opening the file failed. He has Excel 2003. He sent me his Personal.xls file. I changed the name and put it in my XLSTART folder. It works fine with my path. I created his path on my computer and that works fine too. I checked the VBE - Tools - References. The only thing I have checked that he doesn't is "Microsoft Forms 2.0 Object Library". He doesn't have anything like that to check. Does anyone have any ideas of what I could do? Thanks for your time. Otto -- Dave Peterson -- Dave Peterson |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here is another guess -
Change the code to: Do While TheFile < "" If TheFile < "Daily Error report MASTER.xls" Then MsgBox ThePath & "\" & TheFile Set wb = Workbooks.Open(ThePath & "\" & TheFile) make sure you actually need to append the "\" and don't actually have a filename result like: C:\\Report1.xls In windows NT type Operating systems, this will still work, but in Windows 9x, it will error. -- Regards, Tom Ogilvy "rjr" wrote in message . .. Run Time Error 1004 Method OPEN of object.workbooks failed. This is in the Microsoft vb alert window. the Error place in the code is at Do While TheFile < "" If TheFile < "Daily Error report MASTER.xls" Then MsgBox TheFile Set wb = Workbooks.Open(ThePath & "\" & TheFile) << error line. I've sent Otto the files while he was working on the code. The code works perfectly for him at his computer. I can open ALL files from file open or double clicking on the file. "Dave Peterson" wrote in message ... What's the error that is displayed? Any chance that Otto has access to that folder and you don't? Can you open the file just via File|Open? rjr wrote: Hi, I've got the problem that Otto is helping me with. I've done a complete detect and repair and as Chip has suggested I've looked in the References List box and I do have Microsoft Forms 2.0 Object Library installed and checked. I also have the FM20.dll installed and visible. I also attempted to include a user form and it was installed without a hitch, absolutely no problem. I did send the file to Otto and he can't recreate the problem. The code performs as it should on his machine and completes. I still get the error and the code stops, as Otto has said. Is there anything that anyone can think of that I can do that he and I haven't. If uninstalling and reinstalling Excel would work I could do that also. Thanks Bob Reynolds "Chip Pearson" wrote in message ... Do you know the exact wording of the error message? Is it coming from Excel or from VBA? he doesn't is "Microsoft Forms 2.0 Object Library". He doesn't have anything like that to check. That's a big clue. Does he really not have the Forms library listed in the References list box? Even if it not checked, it should be present in the list. MSFORMS is part of the basic Excel installation, not optional in any way. If "Microsoft Forms 2.0 Object Library" doesn't appear at all in the References list, the basic installation of Excel is bad. The first thing I'd advise to your user is to unregister and re-register Excel. Close Excel (and all other Office programs), go to the Windows Start menu, choose Run and enter RegSvr32 "Excel.exe" /unregserver The repeat the process with RegSvr32 "Excel.exe" /regserver You may have to use the full file path of Excel instead of just "Excel.exe". In the Immediate window of VBA, enter the following and press Enter. ?Application.Path & "\Excel.exe" This will display the full pathname of Excel.exe. Use that filename in place of "Excel.exe" in the RegSvr32 commands. Now try to open the workbook. In VBA, ensure that "Microsoft Forms 2.0 Object Library" appears in the list of references. Try adding a UserForm to the project. Doing so will automatically add a reference to MSFORMS. If this fails, and you (by which I mean your user) get an error message when trying to add a UserForm, try to add the reference to MSFORMS manually. In the References dialog, click "Browse" and navigate to the file C:\WINDOWS\system32\FM20.DLL If you find the file, click OK or Open. If you don't find the file, then you'll probably want to run "Detect And Repair" from the Help menu. If this doesn't fix the problem, you'll likely need to uninstall and reinstall Office. A missing MSFORMS reference item and/or a missing FM20.DLL file indicates that something serious has gone on. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "Otto Moehrbach" wrote in message ... Excel XP & Win XP I'm helping an OP with a project. The code loops through all the files in a folder, opens each, does things, closes the file and opens the next file, etc. The code is placed in the Personal.xls file. It works fine for me. It fails on opening the first file for him (will not open the file). An error is produced saying that opening the file failed. He has Excel 2003. He sent me his Personal.xls file. I changed the name and put it in my XLSTART folder. It works fine with my path. I created his path on my computer and that works fine too. I checked the VBE - Tools - References. The only thing I have checked that he doesn't is "Microsoft Forms 2.0 Object Library". He doesn't have anything like that to check. Does anyone have any ideas of what I could do? Thanks for your time. Otto -- Dave Peterson |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
As another note, I removed all macro securtiy and still the problem is
there.. "Dave Peterson" wrote in message ... What's the error that is displayed? Any chance that Otto has access to that folder and you don't? Can you open the file just via File|Open? rjr wrote: Hi, I've got the problem that Otto is helping me with. I've done a complete detect and repair and as Chip has suggested I've looked in the References List box and I do have Microsoft Forms 2.0 Object Library installed and checked. I also have the FM20.dll installed and visible. I also attempted to include a user form and it was installed without a hitch, absolutely no problem. I did send the file to Otto and he can't recreate the problem. The code performs as it should on his machine and completes. I still get the error and the code stops, as Otto has said. Is there anything that anyone can think of that I can do that he and I haven't. If uninstalling and reinstalling Excel would work I could do that also. Thanks Bob Reynolds "Chip Pearson" wrote in message ... Do you know the exact wording of the error message? Is it coming from Excel or from VBA? he doesn't is "Microsoft Forms 2.0 Object Library". He doesn't have anything like that to check. That's a big clue. Does he really not have the Forms library listed in the References list box? Even if it not checked, it should be present in the list. MSFORMS is part of the basic Excel installation, not optional in any way. If "Microsoft Forms 2.0 Object Library" doesn't appear at all in the References list, the basic installation of Excel is bad. The first thing I'd advise to your user is to unregister and re-register Excel. Close Excel (and all other Office programs), go to the Windows Start menu, choose Run and enter RegSvr32 "Excel.exe" /unregserver The repeat the process with RegSvr32 "Excel.exe" /regserver You may have to use the full file path of Excel instead of just "Excel.exe". In the Immediate window of VBA, enter the following and press Enter. ?Application.Path & "\Excel.exe" This will display the full pathname of Excel.exe. Use that filename in place of "Excel.exe" in the RegSvr32 commands. Now try to open the workbook. In VBA, ensure that "Microsoft Forms 2.0 Object Library" appears in the list of references. Try adding a UserForm to the project. Doing so will automatically add a reference to MSFORMS. If this fails, and you (by which I mean your user) get an error message when trying to add a UserForm, try to add the reference to MSFORMS manually. In the References dialog, click "Browse" and navigate to the file C:\WINDOWS\system32\FM20.DLL If you find the file, click OK or Open. If you don't find the file, then you'll probably want to run "Detect And Repair" from the Help menu. If this doesn't fix the problem, you'll likely need to uninstall and reinstall Office. A missing MSFORMS reference item and/or a missing FM20.DLL file indicates that something serious has gone on. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "Otto Moehrbach" wrote in message ... Excel XP & Win XP I'm helping an OP with a project. The code loops through all the files in a folder, opens each, does things, closes the file and opens the next file, etc. The code is placed in the Personal.xls file. It works fine for me. It fails on opening the first file for him (will not open the file). An error is produced saying that opening the file failed. He has Excel 2003. He sent me his Personal.xls file. I changed the name and put it in my XLSTART folder. It works fine with my path. I created his path on my computer and that works fine too. I checked the VBE - Tools - References. The only thing I have checked that he doesn't is "Microsoft Forms 2.0 Object Library". He doesn't have anything like that to check. Does anyone have any ideas of what I could do? Thanks for your time. Otto -- Dave Peterson |
#11
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Since you don't show the code, have him send you the file that fails to open
and test the code with that file. Perhaps the file is damaged or not a file Excel will open. -- Regards, Tom Ogilvy "Otto Moehrbach" wrote in message ... Excel XP & Win XP I'm helping an OP with a project. The code loops through all the files in a folder, opens each, does things, closes the file and opens the next file, etc. The code is placed in the Personal.xls file. It works fine for me. It fails on opening the first file for him (will not open the file). An error is produced saying that opening the file failed. He has Excel 2003. He sent me his Personal.xls file. I changed the name and put it in my XLSTART folder. It works fine with my path. I created his path on my computer and that works fine too. I checked the VBE - Tools - References. The only thing I have checked that he doesn't is "Microsoft Forms 2.0 Object Library". He doesn't have anything like that to check. Does anyone have any ideas of what I could do? Thanks for your time. Otto |
#12
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Tom. He did send me the group of files that he is using, so we both
have the same identical files on both our computers. Otto "Tom Ogilvy" wrote in message ... Since you don't show the code, have him send you the file that fails to open and test the code with that file. Perhaps the file is damaged or not a file Excel will open. -- Regards, Tom Ogilvy "Otto Moehrbach" wrote in message ... Excel XP & Win XP I'm helping an OP with a project. The code loops through all the files in a folder, opens each, does things, closes the file and opens the next file, etc. The code is placed in the Personal.xls file. It works fine for me. It fails on opening the first file for him (will not open the file). An error is produced saying that opening the file failed. He has Excel 2003. He sent me his Personal.xls file. I changed the name and put it in my XLSTART folder. It works fine with my path. I created his path on my computer and that works fine too. I checked the VBE - Tools - References. The only thing I have checked that he doesn't is "Microsoft Forms 2.0 Object Library". He doesn't have anything like that to check. Does anyone have any ideas of what I could do? Thanks for your time. Otto |
#13
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Tom
Thanks for your help as well as Dave and Chip. Here's what the OP and I just did to establish a hard starting point. He set all the code I had written for him aside. Instead, he used the macro from: http://www.contextures.com/xlfaqMac.html#LoopBooks with NO CHANGES of any kind. No other macro or macro call was used. He established a path in his computer to match that used in the macro and placed his test files in that folder. He ran the macro. The error message is: Run-time error '1004' Method 'Open' of object 'Workbook' failed. The highlighted code line is the "Set wb = ............" The full macro is: Sub AllFolderFiles() Dim wb As Workbook Dim TheFile As String Dim MyPath As String MyPath = "C:\Temp" ChDir MyPath TheFile = Dir("*.xls") Do While TheFile < "" Set wb = Workbooks.Open(MyPath & "\" & TheFile) MsgBox wb.FullName wb.Close TheFile = Dir Loop End SubWe will try any suggestion you and the others can come up with. Thanks for your time. Otto"Tom Ogilvy" wrote in message ... Since you don't show the code, have him send you the file that fails to open and test the code with that file. Perhaps the file is damaged or not a file Excel will open. -- Regards, Tom Ogilvy "Otto Moehrbach" wrote in message ... Excel XP & Win XP I'm helping an OP with a project. The code loops through all the files in a folder, opens each, does things, closes the file and opens the next file, etc. The code is placed in the Personal.xls file. It works fine for me. It fails on opening the first file for him (will not open the file). An error is produced saying that opening the file failed. He has Excel 2003. He sent me his Personal.xls file. I changed the name and put it in my XLSTART folder. It works fine with my path. I created his path on my computer and that works fine too. I checked the VBE - Tools - References. The only thing I have checked that he doesn't is "Microsoft Forms 2.0 Object Library". He doesn't have anything like that to check. Does anyone have any ideas of what I could do? Thanks for your time. Otto |
#14
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Otto,
This is out of the blue, but perhaps the user having the problem is using a Macintosh? If this proves to be the case, the code will fail on the line indicated because Macs don't use the '\' character as a path separator. Instead, they use, I think, a ':' character. Instead of hard coding the '\', use Application.PathSeparator. E.g., Set wb = Workbooks.Open(MyPath & Application.PathSeparator & TheFile) The code you posted works fine for me in Excel 2007 for Windows. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "Otto Moehrbach" wrote in message ... Tom Thanks for your help as well as Dave and Chip. Here's what the OP and I just did to establish a hard starting point. He set all the code I had written for him aside. Instead, he used the macro from: http://www.contextures.com/xlfaqMac.html#LoopBooks with NO CHANGES of any kind. No other macro or macro call was used. He established a path in his computer to match that used in the macro and placed his test files in that folder. He ran the macro. The error message is: Run-time error '1004' Method 'Open' of object 'Workbook' failed. The highlighted code line is the "Set wb = ............" The full macro is: Sub AllFolderFiles() Dim wb As Workbook Dim TheFile As String Dim MyPath As String MyPath = "C:\Temp" ChDir MyPath TheFile = Dir("*.xls") Do While TheFile < "" Set wb = Workbooks.Open(MyPath & "\" & TheFile) MsgBox wb.FullName wb.Close TheFile = Dir Loop End SubWe will try any suggestion you and the others can come up with. Thanks for your time. Otto"Tom Ogilvy" wrote in message ... Since you don't show the code, have him send you the file that fails to open and test the code with that file. Perhaps the file is damaged or not a file Excel will open. -- Regards, Tom Ogilvy "Otto Moehrbach" wrote in message ... Excel XP & Win XP I'm helping an OP with a project. The code loops through all the files in a folder, opens each, does things, closes the file and opens the next file, etc. The code is placed in the Personal.xls file. It works fine for me. It fails on opening the first file for him (will not open the file). An error is produced saying that opening the file failed. He has Excel 2003. He sent me his Personal.xls file. I changed the name and put it in my XLSTART folder. It works fine with my path. I created his path on my computer and that works fine too. I checked the VBE - Tools - References. The only thing I have checked that he doesn't is "Microsoft Forms 2.0 Object Library". He doesn't have anything like that to check. Does anyone have any ideas of what I could do? Thanks for your time. Otto |
#15
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello again to all,
I wish it were that simple. Nope I'm windows XP Media Center Edition with all current updates and a valid updated Office Professional product. As a side note I've also placed it on my Dell D520 laptop with Windoes XP Professional and Office 2003 with the exact same results. Since it works for everyone else it obviously has to be something with my computers, but WHAT? My dell laptop is relatively clean without a lot of additional programs and the results are the same. That's why I think the problem lies with my machine's setup... Bob R "Chip Pearson" wrote in message ... Otto, This is out of the blue, but perhaps the user having the problem is using a Macintosh? If this proves to be the case, the code will fail on the line indicated because Macs don't use the '\' character as a path separator. Instead, they use, I think, a ':' character. Instead of hard coding the '\', use Application.PathSeparator. E.g., Set wb = Workbooks.Open(MyPath & Application.PathSeparator & TheFile) The code you posted works fine for me in Excel 2007 for Windows. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "Otto Moehrbach" wrote in message ... Tom Thanks for your help as well as Dave and Chip. Here's what the OP and I just did to establish a hard starting point. He set all the code I had written for him aside. Instead, he used the macro from: http://www.contextures.com/xlfaqMac.html#LoopBooks with NO CHANGES of any kind. No other macro or macro call was used. He established a path in his computer to match that used in the macro and placed his test files in that folder. He ran the macro. The error message is: Run-time error '1004' Method 'Open' of object 'Workbook' failed. The highlighted code line is the "Set wb = ............" The full macro is: Sub AllFolderFiles() Dim wb As Workbook Dim TheFile As String Dim MyPath As String MyPath = "C:\Temp" ChDir MyPath TheFile = Dir("*.xls") Do While TheFile < "" Set wb = Workbooks.Open(MyPath & "\" & TheFile) MsgBox wb.FullName wb.Close TheFile = Dir Loop End SubWe will try any suggestion you and the others can come up with. Thanks for your time. Otto"Tom Ogilvy" wrote in message ... Since you don't show the code, have him send you the file that fails to open and test the code with that file. Perhaps the file is damaged or not a file Excel will open. -- Regards, Tom Ogilvy "Otto Moehrbach" wrote in message ... Excel XP & Win XP I'm helping an OP with a project. The code loops through all the files in a folder, opens each, does things, closes the file and opens the next file, etc. The code is placed in the Personal.xls file. It works fine for me. It fails on opening the first file for him (will not open the file). An error is produced saying that opening the file failed. He has Excel 2003. He sent me his Personal.xls file. I changed the name and put it in my XLSTART folder. It works fine with my path. I created his path on my computer and that works fine too. I checked the VBE - Tools - References. The only thing I have checked that he doesn't is "Microsoft Forms 2.0 Object Library". He doesn't have anything like that to check. Does anyone have any ideas of what I could do? Thanks for your time. Otto |
#16
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
this works for me
Sub AllFolderFiles() Dim wb As Workbook Dim TheFile As String Dim MyPath As String MyPath = "C:\Temp" TheFile = Dir(MyPath & "\" & "*.xls") Do While TheFile < "" Set wb = Workbooks.Open(MyPath & "\" & TheFile) MsgBox wb.FullName wb.Close TheFile = Dir() Loop End Sub -- Gary "rjr" wrote in message .. . Hello again to all, I wish it were that simple. Nope I'm windows XP Media Center Edition with all current updates and a valid updated Office Professional product. As a side note I've also placed it on my Dell D520 laptop with Windoes XP Professional and Office 2003 with the exact same results. Since it works for everyone else it obviously has to be something with my computers, but WHAT? My dell laptop is relatively clean without a lot of additional programs and the results are the same. That's why I think the problem lies with my machine's setup... Bob R "Chip Pearson" wrote in message ... Otto, This is out of the blue, but perhaps the user having the problem is using a Macintosh? If this proves to be the case, the code will fail on the line indicated because Macs don't use the '\' character as a path separator. Instead, they use, I think, a ':' character. Instead of hard coding the '\', use Application.PathSeparator. E.g., Set wb = Workbooks.Open(MyPath & Application.PathSeparator & TheFile) The code you posted works fine for me in Excel 2007 for Windows. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "Otto Moehrbach" wrote in message ... Tom Thanks for your help as well as Dave and Chip. Here's what the OP and I just did to establish a hard starting point. He set all the code I had written for him aside. Instead, he used the macro from: http://www.contextures.com/xlfaqMac.html#LoopBooks with NO CHANGES of any kind. No other macro or macro call was used. He established a path in his computer to match that used in the macro and placed his test files in that folder. He ran the macro. The error message is: Run-time error '1004' Method 'Open' of object 'Workbook' failed. The highlighted code line is the "Set wb = ............" The full macro is: Sub AllFolderFiles() Dim wb As Workbook Dim TheFile As String Dim MyPath As String MyPath = "C:\Temp" ChDir MyPath TheFile = Dir("*.xls") Do While TheFile < "" Set wb = Workbooks.Open(MyPath & "\" & TheFile) MsgBox wb.FullName wb.Close TheFile = Dir Loop End SubWe will try any suggestion you and the others can come up with. Thanks for your time. Otto"Tom Ogilvy" wrote in message ... Since you don't show the code, have him send you the file that fails to open and test the code with that file. Perhaps the file is damaged or not a file Excel will open. -- Regards, Tom Ogilvy "Otto Moehrbach" wrote in message ... Excel XP & Win XP I'm helping an OP with a project. The code loops through all the files in a folder, opens each, does things, closes the file and opens the next file, etc. The code is placed in the Personal.xls file. It works fine for me. It fails on opening the first file for him (will not open the file). An error is produced saying that opening the file failed. He has Excel 2003. He sent me his Personal.xls file. I changed the name and put it in my XLSTART folder. It works fine with my path. I created his path on my computer and that works fine too. I checked the VBE - Tools - References. The only thing I have checked that he doesn't is "Microsoft Forms 2.0 Object Library". He doesn't have anything like that to check. Does anyone have any ideas of what I could do? Thanks for your time. Otto |
#17
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Chip
I will check with him this morning and let you know. It never occurred to me that he might have a Mac. Otto "Chip Pearson" wrote in message ... Otto, This is out of the blue, but perhaps the user having the problem is using a Macintosh? If this proves to be the case, the code will fail on the line indicated because Macs don't use the '\' character as a path separator. Instead, they use, I think, a ':' character. Instead of hard coding the '\', use Application.PathSeparator. E.g., Set wb = Workbooks.Open(MyPath & Application.PathSeparator & TheFile) The code you posted works fine for me in Excel 2007 for Windows. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "Otto Moehrbach" wrote in message ... Tom Thanks for your help as well as Dave and Chip. Here's what the OP and I just did to establish a hard starting point. He set all the code I had written for him aside. Instead, he used the macro from: http://www.contextures.com/xlfaqMac.html#LoopBooks with NO CHANGES of any kind. No other macro or macro call was used. He established a path in his computer to match that used in the macro and placed his test files in that folder. He ran the macro. The error message is: Run-time error '1004' Method 'Open' of object 'Workbook' failed. The highlighted code line is the "Set wb = ............" The full macro is: Sub AllFolderFiles() Dim wb As Workbook Dim TheFile As String Dim MyPath As String MyPath = "C:\Temp" ChDir MyPath TheFile = Dir("*.xls") Do While TheFile < "" Set wb = Workbooks.Open(MyPath & "\" & TheFile) MsgBox wb.FullName wb.Close TheFile = Dir Loop End SubWe will try any suggestion you and the others can come up with. Thanks for your time. Otto"Tom Ogilvy" wrote in message ... Since you don't show the code, have him send you the file that fails to open and test the code with that file. Perhaps the file is damaged or not a file Excel will open. -- Regards, Tom Ogilvy "Otto Moehrbach" wrote in message ... Excel XP & Win XP I'm helping an OP with a project. The code loops through all the files in a folder, opens each, does things, closes the file and opens the next file, etc. The code is placed in the Personal.xls file. It works fine for me. It fails on opening the first file for him (will not open the file). An error is produced saying that opening the file failed. He has Excel 2003. He sent me his Personal.xls file. I changed the name and put it in my XLSTART folder. It works fine with my path. I created his path on my computer and that works fine too. I checked the VBE - Tools - References. The only thing I have checked that he doesn't is "Microsoft Forms 2.0 Object Library". He doesn't have anything like that to check. Does anyone have any ideas of what I could do? Thanks for your time. Otto |
#18
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In a different branch of this thread, Bob wrote that he saw this in the msgbox
for the full name: C:\Documents and Settings\Owner\Desktop\KathleenFolder\asf.xls It doesn't look like it's a MAC (from a non-MAC user). Otto Moehrbach wrote: Chip I will check with him this morning and let you know. It never occurred to me that he might have a Mac. Otto "Chip Pearson" wrote in message ... Otto, This is out of the blue, but perhaps the user having the problem is using a Macintosh? If this proves to be the case, the code will fail on the line indicated because Macs don't use the '\' character as a path separator. Instead, they use, I think, a ':' character. Instead of hard coding the '\', use Application.PathSeparator. E.g., Set wb = Workbooks.Open(MyPath & Application.PathSeparator & TheFile) The code you posted works fine for me in Excel 2007 for Windows. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com (email address is on the web site) "Otto Moehrbach" wrote in message ... Tom Thanks for your help as well as Dave and Chip. Here's what the OP and I just did to establish a hard starting point. He set all the code I had written for him aside. Instead, he used the macro from: http://www.contextures.com/xlfaqMac.html#LoopBooks with NO CHANGES of any kind. No other macro or macro call was used. He established a path in his computer to match that used in the macro and placed his test files in that folder. He ran the macro. The error message is: Run-time error '1004' Method 'Open' of object 'Workbook' failed. The highlighted code line is the "Set wb = ............" The full macro is: Sub AllFolderFiles() Dim wb As Workbook Dim TheFile As String Dim MyPath As String MyPath = "C:\Temp" ChDir MyPath TheFile = Dir("*.xls") Do While TheFile < "" Set wb = Workbooks.Open(MyPath & "\" & TheFile) MsgBox wb.FullName wb.Close TheFile = Dir Loop End SubWe will try any suggestion you and the others can come up with. Thanks for your time. Otto"Tom Ogilvy" wrote in message ... Since you don't show the code, have him send you the file that fails to open and test the code with that file. Perhaps the file is damaged or not a file Excel will open. -- Regards, Tom Ogilvy "Otto Moehrbach" wrote in message ... Excel XP & Win XP I'm helping an OP with a project. The code loops through all the files in a folder, opens each, does things, closes the file and opens the next file, etc. The code is placed in the Personal.xls file. It works fine for me. It fails on opening the first file for him (will not open the file). An error is produced saying that opening the file failed. He has Excel 2003. He sent me his Personal.xls file. I changed the name and put it in my XLSTART folder. It works fine with my path. I created his path on my computer and that works fine too. I checked the VBE - Tools - References. The only thing I have checked that he doesn't is "Microsoft Forms 2.0 Object Library". He doesn't have anything like that to check. Does anyone have any ideas of what I could do? Thanks for your time. Otto -- Dave Peterson |
#19
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Started new here, the others are getting pretty deep.
OK, Have tried using this with several different issues this morning. Here's the outcome. I used the F8 to step through it and see what was happening and also just ran the code and let her rip. I got several messages regarding the files weren't processed, using the full code. and I got a couple there were processed. then using the test code Tom wanted me to last night that worked, I got the first two didn't work, but the rest did as they were supposed to, opened the file and made the specific changes and closed the fiel. The first two files weren't opening as they should and I then opened them both manually and they opened and looked fine, and then I closed them out. They are the first two in alphabetical order. I then changed the order and was able to get two of the 22 to open. The others seemed to hang on et wb = Workbooks.Open(fl.Path) and then went to the error. I've got to go to work today and will try new files, but it would seem to me that if one or more works properly then something in the file would be the problem. Unfortunately all files were saved the same way and all were exported to excel in csv format, the files were opened and then saved as in xls format. Is there a need to put a slight pause into the code that when it attempts to start opening the file it would pause and make sure the file had enough time to open, or am I asking a stupid thing??? Thanks again Bob Reynolds Sub AllFiles() Dim sFol As String Dim fso As Object, fl As Object Dim fld As Object Dim wb As Workbook sFol = "C:\temp" Set fso = CreateObject("Scripting.FileSystemObject") Set fld = fso.GetFolder(sFol) For Each fl In fld.Files if lcase(fl.Path) < lcase(thisworkbook.Fullname) then If fl.Name Like "*.xls" Then On Error Resume Next Set wb = Workbooks.Open(fl.Path) if err.number = 0 then MsgBox wb.FullName wb.Close else msgbox "Not processed: " & fl.Path err.Clear end if On Error goto 0 End If End if Next End Sub |
#20
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello again,
Otto and I have talking this morning and here are some clarifications about what we have discovered. first the source of my files are from a mainframe which saves as a csv file and I open it in MS Excel. Once opened I save it as an Excel .xls file and download it to my computer. All the files that we've been dealing with are of this nature. Otto has asked me to document the downloading process for these files and post them here in case we have a issue with the excel files. I will repost after this evening to see if I can document the process and recreate the issues. If I cant' recreate then it will have to be in the initial files that were saved in excel. If I do recreate the problem I'll return and ask for more advice. I tryly appreciate all of you for sticking by and trying to help me out. Thanks Bob Reynolds Next Otto asked me to clean out the folder and then create new .xls files (blank) and save them in the directory. The names were Book (1) (2) etc... I have six of those files placed in the folder and we discovered there was no problems with the opening and closing of the files. Otto gave me Debra's maco from her werbsite and all seems well at this time. "rjr" wrote in message .. . Started new here, the others are getting pretty deep. OK, Have tried using this with several different issues this morning. Here's the outcome. I used the F8 to step through it and see what was happening and also just ran the code and let her rip. I got several messages regarding the files weren't processed, using the full code. and I got a couple there were processed. then using the test code Tom wanted me to last night that worked, I got the first two didn't work, but the rest did as they were supposed to, opened the file and made the specific changes and closed the fiel. The first two files weren't opening as they should and I then opened them both manually and they opened and looked fine, and then I closed them out. They are the first two in alphabetical order. I then changed the order and was able to get two of the 22 to open. The others seemed to hang on et wb = Workbooks.Open(fl.Path) and then went to the error. I've got to go to work today and will try new files, but it would seem to me that if one or more works properly then something in the file would be the problem. Unfortunately all files were saved the same way and all were exported to excel in csv format, the files were opened and then saved as in xls format. Is there a need to put a slight pause into the code that when it attempts to start opening the file it would pause and make sure the file had enough time to open, or am I asking a stupid thing??? Thanks again Bob Reynolds Sub AllFiles() Dim sFol As String Dim fso As Object, fl As Object Dim fld As Object Dim wb As Workbook sFol = "C:\temp" Set fso = CreateObject("Scripting.FileSystemObject") Set fld = fso.GetFolder(sFol) For Each fl In fld.Files if lcase(fl.Path) < lcase(thisworkbook.Fullname) then If fl.Name Like "*.xls" Then On Error Resume Next Set wb = Workbooks.Open(fl.Path) if err.number = 0 then MsgBox wb.FullName wb.Close else msgbox "Not processed: " & fl.Path err.Clear end if On Error goto 0 End If End if Next End Sub |
#21
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Bob neglected to mention one thing. This morning I had him clear out his
folder of all the .csv - .xls files. Then I had him create new blank Excel files and save them into that folder. About 4-6 files. Then he ran the code from Debra's site. It ran perfectly without a hitch. That's why I asked him to document the procedure that was used to generate his original files (the troublesome files) and post it here for all to peruse. I myself have zero experience with importing non-Excel files into Excel. Otto "rjr" wrote in message . .. Hello again, Otto and I have talking this morning and here are some clarifications about what we have discovered. first the source of my files are from a mainframe which saves as a csv file and I open it in MS Excel. Once opened I save it as an Excel .xls file and download it to my computer. All the files that we've been dealing with are of this nature. Otto has asked me to document the downloading process for these files and post them here in case we have a issue with the excel files. I will repost after this evening to see if I can document the process and recreate the issues. If I cant' recreate then it will have to be in the initial files that were saved in excel. If I do recreate the problem I'll return and ask for more advice. I tryly appreciate all of you for sticking by and trying to help me out. Thanks Bob Reynolds Next Otto asked me to clean out the folder and then create new .xls files (blank) and save them in the directory. The names were Book (1) (2) etc... I have six of those files placed in the folder and we discovered there was no problems with the opening and closing of the files. Otto gave me Debra's maco from her werbsite and all seems well at this time. "rjr" wrote in message .. . Started new here, the others are getting pretty deep. OK, Have tried using this with several different issues this morning. Here's the outcome. I used the F8 to step through it and see what was happening and also just ran the code and let her rip. I got several messages regarding the files weren't processed, using the full code. and I got a couple there were processed. then using the test code Tom wanted me to last night that worked, I got the first two didn't work, but the rest did as they were supposed to, opened the file and made the specific changes and closed the fiel. The first two files weren't opening as they should and I then opened them both manually and they opened and looked fine, and then I closed them out. They are the first two in alphabetical order. I then changed the order and was able to get two of the 22 to open. The others seemed to hang on et wb = Workbooks.Open(fl.Path) and then went to the error. I've got to go to work today and will try new files, but it would seem to me that if one or more works properly then something in the file would be the problem. Unfortunately all files were saved the same way and all were exported to excel in csv format, the files were opened and then saved as in xls format. Is there a need to put a slight pause into the code that when it attempts to start opening the file it would pause and make sure the file had enough time to open, or am I asking a stupid thing??? Thanks again Bob Reynolds Sub AllFiles() Dim sFol As String Dim fso As Object, fl As Object Dim fld As Object Dim wb As Workbook sFol = "C:\temp" Set fso = CreateObject("Scripting.FileSystemObject") Set fld = fso.GetFolder(sFol) For Each fl In fld.Files if lcase(fl.Path) < lcase(thisworkbook.Fullname) then If fl.Name Like "*.xls" Then On Error Resume Next Set wb = Workbooks.Open(fl.Path) if err.number = 0 then MsgBox wb.FullName wb.Close else msgbox "Not processed: " & fl.Path err.Clear end if On Error goto 0 End If End if Next End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Looping thru Files In FolderSub | Excel Programming | |||
Looping through excel files to add to a new workbook | Excel Programming | |||
Looping through files in a folder | Excel Programming | |||
Looping thru files extracting data | Excel Programming | |||
Looping thru files | Excel Programming |