Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 17-07-2012
Member
 
Join Date: Apr 2012
Posts: 33
Getting error when opening excel file using a VB script

I am sure there is something wrong with the VB script code that I am using to open up the Excel file. Every time I tries to open the excel file I get an error messaged popped up saying ?Excel has encountered an error?. Initially I thought there must be problem of compatibility with MS excel and my windows system but later on found that compatibility is not an issue.

Also tried the script on other systems too but the problem is still the same. anyways, below is the code that I am trying to modify and get corrected but it?s not working. Please guide me guys.
Code:
Set objectExcel = CreateObject("Excel.Application")
objectExcel.Workbk.Open "Qualified path\filenm.xlsx"
objectExcel.Visible = True
Reply With Quote
  #2  
Old 17-07-2012
Member
 
Join Date: Nov 2010
Posts: 72
Re: Getting error when opening excel file using a VB script

As far as I can understand I do not see any mistake or error in your vb script code. For opening the excel file the code is proper and fine. It would be much better if you let me know how exactly you try to open the file.

There are possibilities that the problem might be with excel file itself. I would first suggest you to try to open the file without using the vb script code. I mean try to open the file normally by simply double clicking on it and see whether it opens up fine or gives the same error. By looking at the error I feel that excel has some problem and not the script. Try to verify things from MS excel?s side too.
Reply With Quote
  #3  
Old 18-07-2012
Member
 
Join Date: Nov 2010
Posts: 83
Re: Getting error when opening excel file using a VB script

I too believe the same. The problem has to do something with Excel and not just with the VB script. The script looks fine (I have not yet tried it) and also the error message indicates the problem with Excel. I knew that you already checked out your system?s compatibility with Excel but it?s your betterment if you check the version of the Excel software present in your computer. The version of your present Excel software may play a huge role in this problem as you may not know that you are actually trying to open a kind of .xlsx file which is quite new for your Excel version you have. Older version of Excel used to only support .xls extensions extension files whereas the current versions supporst .xlsx extensions.

Verify the version and also the filetype which you are trying to open.
Reply With Quote
  #4  
Old 18-07-2012
Member
 
Join Date: Dec 2010
Posts: 106
Re: Getting error when opening excel file using a VB script

I have got the solution for your problem. First of all let me tell you that do not search of any error in your excel version of the excel file because the error persist in your script and not in the file or something else. The code is well written but unfortunately in your second line you committed a mistake which is disallowing you to target the file name and its path. Below is the code:

Code:
Set objectExcel = CreateObject("Excel.Application")
set wbX = objectExcel.Workbooks.Open("path name\Filename.xlsx")
objectExcel.Visible = True
Reply With Quote
  #5  
Old 18-07-2012
Member
 
Join Date: Mar 2011
Posts: 156
Re: Getting error when opening excel file using a VB script

If in case you aren?t able to still get the problem solved then I would suggest you to try out the following R&D and note down the difference:
  • Firstly for a safer side update your antivirus
  • Try an Excel Diagnostics (to check whether there is no problem with your Excel file and Excel program)
  • Make sure there I no other Excel running instance
  • Within your script, see to it that you have entered the file name and the path name properly, the file location and the file should be existing in your computer
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Getting error when opening excel file using a VB script"
Thread Thread Starter Forum Replies Last Post
Getting Error while opening Microsoft Excel 2000 file in Excel 2003 AbiaA MS Office Support 6 17-02-2012 01:18 PM
Opening file type .tsv with Excel Damned 2 Windows Software 5 12-01-2012 11:12 PM
"The file is corrupt and cannot be opened" error While opening .xls files on office 2010 Excel Myshaa Operating Systems 5 18-04-2011 08:09 AM
How to read and modify excel file using PHP script JamesB Software Development 3 17-03-2009 11:59 PM
Opening an Excel file in VB.NET Braze Software Development 4 26-01-2009 09:03 PM


All times are GMT +5.5. The time now is 08:20 PM.