Results 1 to 2 of 2

Thread: [2005] open word document on click event

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2008
    Posts
    1

    Unhappy [2005] open word document on click event

    i need to open a word document from a button click event. I have tried several things suggested in these forums and none seem to be working.

    I need to be able to open the document "BCCheckSettings2003.doc" from a subdirectory of my documents called "Bookmarks Galore!" .
    Since each user will have a different path to my documents I am thinking I need to get that path first. Here is the code I am using (Thank you RobDogg88, I found the code in your word FAQ's)

    Code:
       Private Sub btnWord03_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWord03.Click
    
            Dim oProcess As New System.Diagnostics.Process
            Dim mydocs As String = Environment.GetFolderPath(Environment.SpecialFolder.Personal)
            'Dim strFileName As String
    
            MsgBox(mydocs)
            mydocs = mydocs & "\" & "Bookmarks Galore" & "\"
            MsgBox(mydocs)
            'strFileName = mydocs & "BCCheckSettings2003.doc"
            'MsgBox(strFileName)
    
    
            With oProcess.StartInfo
                .CreateNoWindow = True
                .WindowStyle = ProcessWindowStyle.Hidden
                .Verb = "open"
                .UseShellExecute = True
                .FileName = mydocs & "BCCheckSettings2003.doc"
            End With
            oProcess.Start()
        End Sub
    it is breaking at the oprocess.start() and telling me it can't find the file.

    Please help! Proejct is overdue.

  2. #2
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Sector 001
    Posts
    1,577

    Re: [2005] open word document on click event

    It is because you have blank spaces in the path.
    http://social.msdn.microsoft.com/For...c-4538944a5806
    VB 2005, Win Xp Pro sp2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width