Viewing Word Docs in Tabs

A

aolson

First of all i am pretty new to VB .NET as a whole so my answer may be
silly as may my questions.
Here is what i would like to do. I would like to open potentially
multiple word documents for viewing only in a tab control. Each Word
document should open in its own tab. Sometimes there may be only 1
document to open, sometimes there may be 5.
I have gotten my app to create the necessary tabs but I can't get more
than one word document to open utilizing the Web Browser object. I am
using an arraylist to store the documents i need to open. If multiple
exist it will open the first one in the first tab, but errors out
stating "Exception of type InvalidActiveXStateException was thrown."
when trying to open the second word doc in the secon tab. Any
suggestions on if this is possible or another way of doing it? Here is
my code:


Try
Dim i As Integer = 0
Dim tbTestTab As TabPage
Do While i < aryTest.Count
tbTestTab = New TabPage
TabControl1.Controls.Add(tbTestTab)
tbTestTab.Name = "tbTab" & i
tbTestTab.Text = "Tab " & i
Dim browser As New AxSHDocVw.AxWebBrowser
browser.Size = New System.Drawing.Size(400, 350)
tbTestTab.Controls.Add(browser)
browser.Navigate2(aryTest(i))
i = i + 1
Loop
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try


Thanks for the assistance and please let me know if there is something
i should be doing differently as this stuff is new to me. Thanks.
 
C

Cor Ligthert [MVP]

Aolson,

Not that I have the answer (I never used a worddocument in the webbrowser),
but because that you are using version 2003 code and tell that you are new.

Are you using version 2003 or version 2005?

Cor
 
C

Cor Ligthert [MVP]

Aolson,

Did you try this already with the designer. Because of the RESX does it give
in my expirience other results than in code. (In this case it is not a
control it is only an interop to an internal webbrowser)

I mean creating the tabpages and than dragging them upon that one by one.

I am not the only one who had in this case better expiriences with the
designer.

I hope this helps,

Cor
 
A

aolson

Unfortunately I can't do it this way as sometimes I will have 4 word
docs to open and other times it may only be one. This being the case i
need to programmatically generate the tabs and the browser control
don't i?
 
C

Cor Ligthert [MVP]

Unfortunately I can't do it this way as sometimes I will have 4 word
docs to open and other times it may only be one. This being the case i
need to programmatically generate the tabs and the browser control
don't i?

Why?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top