473,769 Members | 5,878 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(Cance l As Integer)
Dim file As String
Dim files As String
files = ""
file = Dir$("C:\My Document\Letter s\*.*")
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 8285
jp***@tin.it (Paolo) wrote in message news:<9f******* *************** ***@posting.goo gle.com>...
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(Cance l As Integer)
Dim file As String
Dim files As String
files = ""
file = Dir$("C:\My Document\Letter s\*.*")
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.goo gle.com>...
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(Cance l As Integer)
Dim file As String
Dim files As String
files = ""
file = Dir$("C:\My Document\Letter s\*.*")
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.n et (AccessDev) wrote in message news:<41******* *************** ****@posting.go ogle.com>...
jp***@tin.it (Paolo) wrote in message news:<9f******* *************** ***@posting.goo gle.com>...
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(Cance l As Integer)
Dim file As String
Dim files As String
files = ""
file = Dir$("C:\My Document\Letter s\*.*")
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.n et (AccessDev) wrote in message news:<41******* *************** ****@posting.go ogle.com>...
jp***@tin.it (Paolo) wrote in message news:<9f******* *************** ***@posting.goo gle.com>...
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(Cance l As Integer)
Dim file As String
Dim files As String
files = ""
file = Dir$("C:\My Document\Letter s\*.*")
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.Documen ts.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
4529
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. Manually, this would be: - Start MS Word (am using Office 2003)
3
4920
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 opening in IE. I think I should be able to do it with javascript to open word and then call that function on the link to the doc. Can someone give me some pointers? Thanks in advance.
3
5813
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 in advance
8
9172
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 C can be used to perform this task. Thanks you so much
8
3181
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 = "C:\\test.doc"; object readOnly = false;
2
1493
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 connection/dataadapter/dataset method. I've gotten to the point where I can output the path as a string in a message box. Does anybody know a function that would allow me to open that file in its associated application? In other words, when I cause...
6
3107
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 highly appreciated
0
3231
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 to register new customer or companies they will enter the information in Windows Form and the program automaticaly creates the WORD document under specific folder under application path. Once the empty word file created than ask user if they want...
2
5547
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 document in linux server without COM class.
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10215
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7410
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5307
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3964
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3564
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.