472,356 Members | 2,060 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,356 software developers and data experts.

Open Word File using Dir Function

Friends,

I have created a form with a list box that shows all my Word files.
I have then added the following code (found on comp.databases
newsgroup) to the Open event of my form and it works fine:

Private Sub Form_Open(Cancel As Integer)
Dim file As String
Dim files As String
files = ""
file = Dir$("C:\My Document\Letters\*.*")
While Len(file) > 0
files = files & file & ";"
file = Dir$
Wend
List1.RowSource = files
End Sub

What I would now like is to be able to open the selected file by
clicking on it from the listbox. Is this possible?

Thanks.
Nov 12 '05 #1
5 8173
jp***@tin.it (Paolo) wrote in message news:<9f*************************@posting.google.c om>...
Friends,

I have created a form with a list box that shows all my Word files.
I have then added the following code (found on comp.databases
newsgroup) to the Open event of my form and it works fine:

Private Sub Form_Open(Cancel As Integer)
Dim file As String
Dim files As String
files = ""
file = Dir$("C:\My Document\Letters\*.*")
While Len(file) > 0
files = files & file & ";"
file = Dir$
Wend
List1.RowSource = files
End Sub

What I would now like is to be able to open the selected file by
clicking on it from the listbox. Is this possible?

Thanks.


you could put code to automate Word in your double-click event of the
listbox and pass in the itemselected collection... of course, you
could probably also just use the OpenFile API at www.mvps.org/access
Nov 12 '05 #2
jp***@tin.it (Paolo) wrote in message news:<9f*************************@posting.google.c om>...
Friends,

I have created a form with a list box that shows all my Word files.
I have then added the following code (found on comp.databases
newsgroup) to the Open event of my form and it works fine:

Private Sub Form_Open(Cancel As Integer)
Dim file As String
Dim files As String
files = ""
file = Dir$("C:\My Document\Letters\*.*")
While Len(file) > 0
files = files & file & ";"
file = Dir$
Wend
List1.RowSource = files
End Sub

What I would now like is to be able to open the selected file by
clicking on it from the listbox. Is this possible?

Thanks.

Simply add the code to the OnClick event property of the list box so
that it will open MS Word and the specified document. Do you have that
code?
Ted
Nov 12 '05 #3
Thanks Ted,

No I do not have that code and would really appreciate your help.

Thanks.

Ac*******@att.net (AccessDev) wrote in message news:<41**************************@posting.google. com>...
jp***@tin.it (Paolo) wrote in message news:<9f*************************@posting.google.c om>...
Friends,

I have created a form with a list box that shows all my Word files.
I have then added the following code (found on comp.databases
newsgroup) to the Open event of my form and it works fine:

Private Sub Form_Open(Cancel As Integer)
Dim file As String
Dim files As String
files = ""
file = Dir$("C:\My Document\Letters\*.*")
While Len(file) > 0
files = files & file & ";"
file = Dir$
Wend
List1.RowSource = files
End Sub

What I would now like is to be able to open the selected file by
clicking on it from the listbox. Is this possible?

Thanks.

Simply add the code to the OnClick event property of the list box so
that it will open MS Word and the specified document. Do you have that
code?
Ted

Nov 12 '05 #4
Thanks Ted,

No I do not have that code and would appreciate you help.

Thanks.

Ac*******@att.net (AccessDev) wrote in message news:<41**************************@posting.google. com>...
jp***@tin.it (Paolo) wrote in message news:<9f*************************@posting.google.c om>...
Friends,

I have created a form with a list box that shows all my Word files.
I have then added the following code (found on comp.databases
newsgroup) to the Open event of my form and it works fine:

Private Sub Form_Open(Cancel As Integer)
Dim file As String
Dim files As String
files = ""
file = Dir$("C:\My Document\Letters\*.*")
While Len(file) > 0
files = files & file & ";"
file = Dir$
Wend
List1.RowSource = files
End Sub

What I would now like is to be able to open the selected file by
clicking on it from the listbox. Is this possible?

Thanks.

Simply add the code to the OnClick event property of the list box so
that it will open MS Word and the specified document. Do you have that
code?
Ted

Nov 12 '05 #5
You'll probably want the fIsAppRunning() function, and then if Word is
running, just activate it and then use AppWord.Documents.Add(strFile).

http://www.mvps.org/access/api/api0007.htm

see here:
http://www.mvps.org/access/modules/mdl0006.htm

for an example of using the function... (He's using Excel, but the
differences are really minor.)
HTH,
pieter
Nov 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Martin Lucas-Smith | last post by:
I am trying to use PHP's COM support to open a URL from within MS Word then save the document. I am using PHP5.0.3/Apache2/WindowsXP. phpinfo() confirms that COM support is enabled. ...
3
by: TLMM | last post by:
I have a Word doc already created that I want to open from an asp page. I want it to open in Word and allow the user to modify if necessary. I currently have it opening (using href), but it is...
3
by: Andy Davis | last post by:
How do i or can I open a word document directly from Access? I would like to be able for the user to click a button on my form to open a word document and then also run a macro in Word. Thanks...
8
by: Asma | last post by:
Dear Sir, I am trying to find a way to open a Word document using C language and read the text of word doc into a variable. (Turbo C on Dos 6.0). Can anyone please tell me which libraries in...
8
by: sudha | last post by:
Hi, To open a word doc from c#, i use the following code : Word.ApplicationClass WordApp = new Word.ApplicationClass (); // give any file name of your choice. object fileName =...
2
by: Michael Sutherland | last post by:
I'm attempting to use a Hyperlink within a database to open an outside Acrobat or Word file. I've placed the path into the database, and I've accessed the path in my program via the normal...
6
by: Moumen VB.NET 2003/2005 Developer | last post by:
How can I detect if a file sitting on a network drive is still open by another application? This application resides on another machine on the network? I am using VB.NET 2003 Your help is...
0
by: Niyazi | last post by:
Hi, I created application that store the data in SQL SERVER that reside on network. The client also use this application to access the resources provided with application. But is the client want...
2
by: arivusudar.nc | last post by:
I have to open word document in web page using php coding in linux server.. already i worte in windows supporting php code. but it is not working in my linux server so, i need how to open word...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.