+ Reply to Thread
Results 1 to 5 of 5

Open a document using VBA

Hybrid View

  1. #1
    Registered User
    Join Date
    01-11-2005
    Posts
    64

    Unhappy Open a document using VBA

    Hi,

    This should be very simple, but it doesn't work for some reason! I'm trying to open a file name when the user clicks on a command button and here is the code I'm using:

    Private Sub CommandButton1_Click()
    Documents.Open ("C:\Test.doc")
    End Sub


    I've also tried using Application.GetOpenFilename, but still no joy.

    Please help.

    Many thanks,

    Anar

  2. #2
    Ozgur Pars
    Guest

    RE: Open a document using VBA

    Workbooks.Open Filename:="R:\xxx\yyy.xls"

    Hope it helps,
    Ozgur
    "anar_baku" wrote:

    >
    > Hi,
    >
    > This should be very simple, but it doesn't work for some reason! I'm
    > trying to open a file name when the user clicks on a command button and
    > here is the code I'm using:
    >
    > Private Sub CommandButton1_Click()
    > Documents.Open ("C:\Test.doc")
    > End Sub
    >
    > I've also tried using Application.GetOpenFilename, but still no joy.
    >
    > Please help.
    >
    > Many thanks,
    >
    > Anar
    >
    >
    > --
    > anar_baku
    > ------------------------------------------------------------------------
    > anar_baku's Profile: http://www.excelforum.com/member.php...o&userid=18259
    > View this thread: http://www.excelforum.com/showthread...hreadid=540260
    >
    >


  3. #3
    Registered User
    Join Date
    01-11-2005
    Posts
    64
    This works fine for files that can open in Excel, but not for those that can't. I'm trying to open .doc/.pdf files. Any alternatives?

    Quote Originally Posted by Ozgur Pars
    Workbooks.Open Filename:="R:\xxx\yyy.xls"

    Hope it helps,
    Ozgur
    "anar_baku" wrote:

    >
    > Hi,
    >
    > This should be very simple, but it doesn't work for some reason! I'm
    > trying to open a file name when the user clicks on a command button and
    > here is the code I'm using:
    >
    > Private Sub CommandButton1_Click()
    > Documents.Open ("C:\Test.doc")
    > End Sub
    >
    > I've also tried using Application.GetOpenFilename, but still no joy.
    >
    > Please help.
    >
    > Many thanks,
    >
    > Anar
    >
    >
    > --
    > anar_baku
    > ------------------------------------------------------------------------
    > anar_baku's Profile: http://www.excelforum.com/member.php...o&userid=18259
    > View this thread: http://www.excelforum.com/showthread...hreadid=540260
    >
    >

  4. #4
    Registered User
    Join Date
    01-11-2005
    Posts
    64

    Talking

    In case anyone needs it, I've now found a simple way:
    ActiveWorkbook.FollowHyperlink Address:="C:\File.xxx", NewWindow:=True

  5. #5
    Ozgur Pars
    Guest

    Re: Open a document using VBA

    For word documents you can use:
    Documents.Open FileName:="c:\xxx.doc"

    or alternatively:

    Sub AAA()
    Dim App As Application
    Dim W As Document

    Set App = Word.Application
    Set W = app.Documents.Open("c:\xxx.doc")
    End Sub

    Just call AAA in your code...



    "anar_baku" wrote:

    >
    > This works fine for files that can open in Excel, but not for those that
    > can't. I'm trying to open .doc/.pdf files. Any alternatives?
    >
    > Ozgur Pars Wrote:
    > > Workbooks.Open Filename:="R:\xxx\yyy.xls"
    > >
    > > Hope it helps,
    > > Ozgur
    > > "anar_baku" wrote:
    > >
    > > >
    > > > Hi,
    > > >
    > > > This should be very simple, but it doesn't work for some reason! I'm
    > > > trying to open a file name when the user clicks on a command button

    > > and
    > > > here is the code I'm using:
    > > >
    > > > Private Sub CommandButton1_Click()
    > > > Documents.Open ("C:\Test.doc")
    > > > End Sub
    > > >
    > > > I've also tried using Application.GetOpenFilename, but still no joy.
    > > >
    > > > Please help.
    > > >
    > > > Many thanks,
    > > >
    > > > Anar
    > > >
    > > >
    > > > --
    > > > anar_baku
    > > >

    > > ------------------------------------------------------------------------
    > > > anar_baku's Profile:

    > > http://www.excelforum.com/member.php...o&userid=18259
    > > > View this thread:

    > > http://www.excelforum.com/showthread...hreadid=540260
    > > >
    > > >

    >
    >
    > --
    > anar_baku
    > ------------------------------------------------------------------------
    > anar_baku's Profile: http://www.excelforum.com/member.php...o&userid=18259
    > View this thread: http://www.excelforum.com/showthread...hreadid=540260
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1