Results 1 to 5 of 5

Thread: Getting error when opening excel file using a VB script

  1. #1
    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

  2. #2
    Join Date
    Nov 2010
    Posts
    73

    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.

  3. #3
    Join Date
    Nov 2010
    Posts
    86

    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.

  4. #4
    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

  5. #5
    Join Date
    Mar 2011
    Posts
    160

    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

Similar Threads

  1. Replies: 6
    Last Post: 17-02-2012, 01:18 PM
  2. Opening file type .tsv with Excel
    By Damned 2 in forum Windows Software
    Replies: 5
    Last Post: 12-01-2012, 11:12 PM
  3. Replies: 5
    Last Post: 18-04-2011, 08:09 AM
  4. How to read and modify excel file using PHP script
    By JamesB in forum Software Development
    Replies: 3
    Last Post: 17-03-2009, 11:59 PM
  5. Opening an Excel file in VB.NET
    By Braze in forum Software Development
    Replies: 4
    Last Post: 26-01-2009, 09:03 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,536,763.67922 seconds with 17 queries