|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Need to start word 2003 and show existing rtf doc in VB.Netit, 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 word..Visible = True
Show quoteHide quote "Bob" <bduf***@sgiims.com> wrote in message news:edqe3xKiGHA.2268@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 > > > > |
|||||||||||||||||||||||