+ Reply to Thread
Results 1 to 3 of 3

Is there a Size limitation when writing from VB -> Excel?

Hybrid View

  1. #1
    Tif!
    Guest

    Is there a Size limitation when writing from VB -> Excel?

    Dim objData as Variant
    objData = <a string>
    objXLWorkBook.Sheets("Sheet1").Range(<whatever>).Value = objData

    If objData is a string around 200 characters long, all is fine and my
    string gets written the the cell as expected. If objData is a string
    around 1000 character long, I get Error number 1004
    "Applicaiton-defined or object-defined error". Is there a size
    limitation? I can manually enter 1000 characters into an Excel
    spreadsheet just fine.


  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Tif!

    Ther is probable an issue with your code. I used the following code on my machine and it worked fine. I am running Office 2000 on Windows XP. Try this code out on your end and see if you still have the same problem.

    Sub Test()
      
      Dim I, S
      
      For I = 1 To 1000
       S = Str(I) & S
      Next I
      
      Range("A1").Value = S
      
    End Sub
    Sincerely,
    Leith Ross

  3. #3
    Tif!
    Guest

    Re: Is there a Size limitation when writing from VB -> Excel?

    You're reply prompted me to try something different and it worked!
    When I tried writing to a large range of cells using:

    objXLWorkBook.Sheets("Sheet1").Range("A1:M3000").Value = <my
    multidimensional array of variants>

    It throws the 1004 error when the contents of a certain cell are too
    big (somewhere between 200 and 1000 characters). But, if I write to
    individual cells using:

    objXLWorkBook.Sheets("Sheet1").Cells("A1").Value = <one element of my
    multidimensional array of variants>

    I can enter in data as big as 6000 characters.

    So, not sure "why" this works, but I'm using it! Thanks for the reply!


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1