1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

VB 6 runtime error

Discussion in 'Software Development' started by lamstaldy, Jan 30, 2003.

Thread Status:
Not open for further replies.
  1. lamstaldy

    lamstaldy Thread Starter

    Joined:
    Dec 15, 2001
    Messages:
    113
    I'm writing a vb app that gets data over the comm port, manipulates the data, and then stores the data in Excel. My error occurs when I format the columns in Excel. I use the With statement to set the width of the first 10 columns. This works fine the first time I open Excel. However, if I close Excel and then open Excel (from within my app) I get "Run-time error '1004': Method 'Columns' of object '_Global' failed". If I get rid of the With statement and precede all my column format lines with the ExcelSheet object name then everything works ok.
     
  2. lamstaldy

    lamstaldy Thread Starter

    Joined:
    Dec 15, 2001
    Messages:
    113
    I just re-read my original post and realized that it is nearly incomprehensible. I've attached a ZIP file (renamed as .txt) that includes two vb projects and two vb forms. One project works and the other causes an error if you open, then close, and then open Excel using the command buttons. The only difference between the two is the use of a With statement. I've changed my original project to eliminate the With statement, but I'm still interested in knowing why this happens.
     

    Attached Files:

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/116131

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice