Dea Cris

Hi,

Hopefully I'll get an oppinion from you guys.

I am trying to open a .DOC file, copy the content (just text and tables) in a variable and close the file. It works for 300 files, but after 330 (let's say) Windows generates the error in the subject.

The code I use is this:


Re: Visual Basic Express Edition Error in opening .DOC "There is not enaugh memory or disk space to run Word"

DMan1

With the code you have above you are creating a new instance of the word application for every iteration of the loop...step one; take the app out of the loop:...you don't need 300 instances of word to work with 300 word docs

Dim wordApp As Word.Application

Dim docWord As Word.Document

wordApp = New Word.Application

For index = 0 To n - 1

docWord = New Word.Document






Re: Visual Basic Express Edition Error in opening .DOC "There is not enaugh memory or disk space to run Word"

Dea Cris

Thanks for the answer DMan 1 . I wish it was that easy.

I have tried that. It doesn't really work. If I do that I get the error: "Object reference not set to an instance of an object. Troubleshooting tips: Use the "new" keyword to create an object instance" , and that is how I got to this form, with the instantiation inside the FOR loop.






Re: Visual Basic Express Edition Error in opening .DOC "There is not enaugh memory or disk space to run Word"

DMan1

Well I believe it really is that easy...I've tested the following and seems to work just fine...of course depending on your system configuration there will still be a physical limitation to the number of open docs you can have at one time

Imports WD = Microsoft.Office.Interop.Word

Public Class Form1

Public Sub TestWord()

Dim wordApp As WD.Application

wordApp = New WD.Application

wordApp.Visible = True

For index As Integer = 0 To 100

Dim docWord As New WD.Document

docWord.Select()

Next

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

TestWord()

End Sub

End Class






Re: Visual Basic Express Edition Error in opening .DOC "There is not enaugh memory or disk space to run Word"

Dea Cris

Yes, it worked!

Thanks DMan1 !

PS: It doesn't matter what I did wrong...