DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2010
    Posts
    12

    Linking excel & word documents

    Hi - I need help!!

    I want to use a form with buttons on to link to open excel files or word documents. Therefore the files need to be available to the program which must run from a CD. (need the CD to be in always).

    I have added the files to resources and see them in the solution explorer bin folder. I have also made them "copy always" in the file properties. See path of attendance register in sloution explorer.
    Test1/bin/Debug/resourses/Attendance register. doc.

    I need the code for the buttons. I know it needs to be relative path but thats as far as me knowing goes.

    I am using visual studio 2005 (programming in VB) , windows7, office 2007 but save files as 2003.

    Urgently need help so that I can move on, battling for 3 weeks no luck!!!

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Try this:

    Dim FileName As String = "Resources\Attendance Register.doc"
    System.Diagnostics.Process.Start(FileName)
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Apr 2010
    Posts
    12

    Linking need help

    I tried it but as soon as it is installed on another pc it does not see the link to the document.

    I get error message " Unhandled exception error" The system cannot find the file specified.

  4. #4
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Is the document in a "Resources" folder under the folder where your .EXE is installed?
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  5. #5
    Join Date
    Apr 2010
    Posts
    12

    Linking files

    I have attached a snip from solution explorer, is it?? see attached file

    Code:
    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

    Thats what I've been trying - I know its wrong but at least you can see what I've done

    Thanks for your input so far
    Attached Images
    Last edited by SG01; 04-15-2010 at 02:03 AM.

  6. #6
    Join Date
    Feb 2004
    Location
    Longueuil, Québec
    Posts
    577
    The path you gave "C:\Users\admin\Documents\Visual Studio 2005\Projects\Test1\Test1\bin\Debug" is the development path. I would be very surprised if the path was the same on the other machine.

    And even the application is installed in My Documents ("C:\Users\admin\Documents") on the test machine, this path can change name between different versions of Windows.

    Try with Path.Combine(Application.StartupPath , "Resources\Attendance Register.doc"), which is a reference to where the application is installed.
    Jacques Bourgeois
    JBFI
    http://www3.sympatico.ca/jbfi/homeus.htm

Similar Threads

  1. search excel from word and import results
    By excelusa in forum VB Classic
    Replies: 0
    Last Post: 05-02-2009, 02:41 AM
  2. Excel & Word - Access Denied
    By krishna170978 in forum .NET
    Replies: 0
    Last Post: 01-04-2006, 11:55 AM
  3. Replies: 0
    Last Post: 05-15-2003, 06:20 PM
  4. Converting MS Word Documents to html thru ASPs..
    By Chris Schmidt in forum ASP.NET
    Replies: 0
    Last Post: 12-13-2000, 03:59 PM
  5. Manipulating Word Documents
    By Matt Hodge in forum Web
    Replies: 1
    Last Post: 04-12-2000, 03:51 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links