Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.word.tables
Sam Sam is offline
external usenet poster
 
Posts: 68
Default memory could not be read error using tables in MS Word 2003

Hi,
I am trying to create a word document programatically in vb.net 2003.The
program would create a blank word document, insert a table and populate it
with some values.
my program does successfully create the word document, inserts table and
populates it.The probelm I am running into is that just before the program
ends I get the following error message:
Application Error: The instruction at "0x5b261e4e" referenced memory at
"0x0454e2c8". The memory could not be "read" Click on OK to terminate the
program.

I dont get this error message if I insert sentences instead of table.

Here's the code snippet that inserts table:

With currentSelection
Dim sTableRng As Word.Range = sWord.Selection.Range

sDoc.Tables.Add(sTableRng, sRowCount, sColCount)

'Add table row headings
With sDoc.Tables.Item(1)
'Format the headings
.Cell(1, 1).Range.Font.Bold = True
.Cell(1, 2).Range.Font.Bold = True
.Cell(1, 3).Range.Font.Bold = True

'Enter heading names
.Cell(1, 1).Range.Text = "Item Name"
.Cell(1, 2).Range.Text = "Type"
.Cell(1, 3).Range.Text = "Width"
End With

'Add values into the table
'Declare variable to iterate through rows of table
Dim sTI As Integer

'Enter field values
For sTI = 2 To sRowCount + 1
With sDoc.Tables.Item(1)
'Format the headings
.Cell(sTI, 1).Range.Font.Bold = False
.Cell(sTI, 2).Range.Font.Bold = False
.Cell(sTI, 3).Range.Font.Bold = False

'Enter heading names
.Cell(sTI, 1).Range.Text = "Item1"
.Cell(sTI, 2).Range.Text = "Type1"
.Cell(sTI, 3).Range.Text = "Width1"
End With
Next
sTableRng = Nothing
End With

I tried the releaseCOMobject method at the end to close any open
connections, but that did not help either.

Any help is greatly appreciated.

Thanks

Sam
 
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting WordPerfect 12 files to Word 2003 Curious New Users 4 May 19th 23 02:48 PM
Why dont MS just f**king re-write Word from scratch? Its dogsh*t Word Hater Microsoft Word Help 33 May 5th 23 02:52 PM
take yet another lesson from wordperfect "reveal codes" wordperfect is superior Microsoft Word Help 5 May 11th 09 07:58 PM
hard space between words. Sandy L Microsoft Word Help 7 May 5th 06 08:25 PM
Is there a way to "join" tables in Word 2003? Julian Turner Tables 3 October 28th 04 06:51 PM


All times are GMT +1. The time now is 08:34 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"