By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,133 Members | 1,113 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,133 IT Pros & Developers. It's quick & easy.

Need to start word 2003 and show existing rtf doc in VB.Net

P: n/a
Bob
I have the follwing snippet of code, lets me find a document and then open
it, but thw word application does not show up.

I had similara to this in vb6 and it worked, but I can't get it to show in
Vs2005 Vb.Net

Can anyone tell me how to show the word application from within VB.net. I
need this and I need to be able to add a new file.
I'll have two diffrent menu items. the edit existing file and the add new
word file menu.
Here's the snippet I got for the Edit existing file, It doe something but
doesn't show word on screen.

Private Sub mnuOpenAndModWord_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles mnuOpenAndModWord.Click

Dim Wordfolder As String

Wordfolder = My.Settings.DefaultOriginalTextFilesFolders

Me.ofdWordDoc.InitialDirectory = Wordfolder

If ofdWordDoc.ShowDialog() = System.Windows.Forms.DialogResult.OK Then

Dim WordFile As String

WordFile = Me.ofdWordDoc.FileName

Me.Cursor = Cursors.WaitCursor

Dim word As New Microsoft.Office.Interop.Word.Application

Dim doc As Microsoft.Office.Interop.Word.Document

Try

doc = word.Documents.Open(WordFile)

doc.Activate()

Catch ex As COMException

MessageBox.Show("Error accessing Word document.")

End Try

Me.Cursor = Cursors.Default

Else

End If

End Sub

Any help would be appreciated,

Bob


Jun 5 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
RMT

word..Visible = True

"Bob" <bd*****@sgiims.com> wrote in message
news:ed**************@TK2MSFTNGP04.phx.gbl...
I have the follwing snippet of code, lets me find a document and then open
it, but thw word application does not show up.

I had similara to this in vb6 and it worked, but I can't get it to show in
Vs2005 Vb.Net

Can anyone tell me how to show the word application from within VB.net. I
need this and I need to be able to add a new file.
I'll have two diffrent menu items. the edit existing file and the add new
word file menu.
Here's the snippet I got for the Edit existing file, It doe something but
doesn't show word on screen.

Private Sub mnuOpenAndModWord_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles mnuOpenAndModWord.Click

Dim Wordfolder As String

Wordfolder = My.Settings.DefaultOriginalTextFilesFolders

Me.ofdWordDoc.InitialDirectory = Wordfolder

If ofdWordDoc.ShowDialog() = System.Windows.Forms.DialogResult.OK Then

Dim WordFile As String

WordFile = Me.ofdWordDoc.FileName

Me.Cursor = Cursors.WaitCursor

Dim word As New Microsoft.Office.Interop.Word.Application

Dim doc As Microsoft.Office.Interop.Word.Document

Try

doc = word.Documents.Open(WordFile)

doc.Activate()

Catch ex As COMException

MessageBox.Show("Error accessing Word document.")

End Try

Me.Cursor = Cursors.Default

Else

End If

End Sub

Any help would be appreciated,

Bob

Jun 5 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.