Consulting

Results 1 to 5 of 5

Thread: Solved: Opening a doc

  1. #1

    Solved: Opening a doc

    HI

    I have this code beind a commandbutton:

    [vba]
    Documents.Open FileName:="C:\sh.doc"
    [/vba]

    However a error message keeps occuring say object not found, I have tried mutiple locations (placing the doc in different locations and changing the code)

    ?

  2. #2
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    Is this in Word or Excel?

    Because you've posted in the Excel section.

  3. #3
    Excel, I want to open a word document using vba with my userform within excel

  4. #4
    VBAX Mentor CBrine's Avatar
    Joined
    Jun 2004
    Location
    Toronto, Canada
    Posts
    387
    Location
    bopo,
    Requires a little more work from Excel.

    [VBA]

    Sub OpenWord()
    Dim newApp As Object
    Set newApp = GetObject("C:\test.doc")
    newApp.Application.Visible = True
    End Sub
    [/VBA]

    HTH
    Cal
    The most difficult errors to resolve are the one's you know you didn't make.


  5. #5
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    or
    [VBA]Sub OpenWord()
    ActiveWorkbook.FollowHyperlink "C:\test.doc"
    End Sub
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

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