I am battling with this code.
I want to open a word document from a button and want the document (attendance register) to be available to resources once compiled and using on CD from another PC.
At present having issues getting it right!!!

Public Class Form2
Private WordApp As New Microsoft.Office.Interop.Word.Application

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

'If Me.OpenFileDialog1.ShowDialog() = DialogResult.OK Then
'Dim fileName As Object = OpenFileDialog1.FileName
Dim fileName As Object = "C:\Users\admin\Documents\Visual Studio 2005\Projects\Test1\Test1\bin\Debug\Resources\Attendance Register.doc"
'Dim readOnly as Object = False
Dim isVisible As Object = True
Dim missing As Object = System.Reflection.Missing.Value
WordApp.Visible = True
Dim aDoc As Microsoft.Office.Interop.Word.Document
aDoc = WordApp.Documents.Open(fileName, , False, False, , , True)
Me.Hide()

'End If
End Sub

I am using visual Studio 2005 proffesional, windows7, Office 2007 but saving doc's as 2003.

Please it's been 3 weeks that I am not getting it right, see if anyone can help

Recommended Answers

All 5 Replies

bump, can anyone help !!! Please

Do you want to save the .doc file into the project and when you give the programm to another user, and he clicks the button, to open the file?

Yes that is what I want to do. Press button to open a file.

Later want to add a single input so that a logo can be added to all documents.

About the doc file, all you need to do is:
1)add the .doc file to your project
2)Configure the compile settings of the file...

if you need any further help contact me.

Hey, if you were wanting to modify the word document later I would suggest staying closer to the method you have at the moment but to open a new process is

System.Diagnostics.Process.Start("C:\Users\Username\Documents\filex.doc")
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.