Browse for documents (using explorer)

  • Thread starter Thread starter Niklas Östergren
  • Start date Start date
N

Niklas Östergren

God morning!

I´m about to create a possability for my users to create a msg which have
attachment linked to the msg and then linke the msg to all e-mail address
that the msg (with attachments) have been sent to. So the user can store
every dispatch and se who have recived what and when.

I know that it should be possible to add documents (word documents, Excell
files, pictures etc.) to a table in Access. I have allready created a set of
tables for storing e-mail message (only the text) and 2 related tables (one
for storing documents [ActiveX-Object] and one for relate between these
documents and the e-mail msg.).

But how do I do to let the user browse for the files they want to attache to
the e-mail msg?

I have a form <frmDispatchMsg> (holding the msg) and a subform
<frmsubDispatchMsgDocumentAttachment> (holding the attachments).

From the subform it´s possible to right-click and select "Attache-document".
But this isn´t verry user friendly since the user then have to select
"Browse" to get to the place I´d like to open up with one mous-click (the
explorer window.

Is there any KB or any place in internet I can read about how to do this?

More specific I´d like to open up the explorer window in which I select
which file (any type) I´d like to store in my table (tblDocument) in a
ActiveX-field.

How to then link this document to the DispatchMsg is easy. But how do I get
the document in to the table?

Next Q is:
- Since there isn´t any possability (as far as I know of) to open up either
a combobox or a listbox showing all ActiveX-document stored in tblDocuemnt.
How do I show, in a form, which document that is allready stored in
tblDocuemnt for the user?

Finaly:
- Is there a way to retrive, from the explorer when I store the document in
my table <tblDocment> the name of the file so I can show that instead of
[Microsoft Word document] or [Microsoft Photo Editor 3.0-foto]. This isn´t
either verry userfriendly?

TIA!
// Niklas
 
Hi Niklas

First, I advise you NOT to try to store the contents of your documents in
the database. This will lead to enormouos database bloat, and will
contribute to the likelihood of corruption.

Instead, store only the path and filename of the document.

To browse for documents, you can use the standard Windows File Open dialog.
There is some code here to do this:
http://www.mvps.org/access/api/api0001.htm
 
Hi Graham!

OK, I listen to what you say and I´ll follow your advise.

But I do have some Q about this though!

Is it possible, from storing the path, to open up the document which path is
stored. Either by a cmd or double_click on the path. Someway to make it easy
for the user to open the attached file?

Thanks for the advice!

// Niklas


Graham Mandeno said:
Hi Niklas

First, I advise you NOT to try to store the contents of your documents in
the database. This will lead to enormouos database bloat, and will
contribute to the likelihood of corruption.

Instead, store only the path and filename of the document.

To browse for documents, you can use the standard Windows File Open dialog.
There is some code here to do this:
http://www.mvps.org/access/api/api0001.htm

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Niklas Östergren said:
God morning!

I´m about to create a possability for my users to create a msg which have
attachment linked to the msg and then linke the msg to all e-mail address
that the msg (with attachments) have been sent to. So the user can store
every dispatch and se who have recived what and when.

I know that it should be possible to add documents (word documents, Excell
files, pictures etc.) to a table in Access. I have allready created a set
of
tables for storing e-mail message (only the text) and 2 related tables
(one
for storing documents [ActiveX-Object] and one for relate between these
documents and the e-mail msg.).

But how do I do to let the user browse for the files they want to attache
to
the e-mail msg?

I have a form <frmDispatchMsg> (holding the msg) and a subform
<frmsubDispatchMsgDocumentAttachment> (holding the attachments).

From the subform it´s possible to right-click and select
"Attache-document".
But this isn´t verry user friendly since the user then have to select
"Browse" to get to the place I´d like to open up with one mous-click (the
explorer window.

Is there any KB or any place in internet I can read about how to do this?

More specific I´d like to open up the explorer window in which I select
which file (any type) I´d like to store in my table (tblDocument) in a
ActiveX-field.

How to then link this document to the DispatchMsg is easy. But how do I
get
the document in to the table?

Next Q is:
- Since there isn´t any possability (as far as I know of) to open up
either
a combobox or a listbox showing all ActiveX-document stored in
tblDocuemnt.
How do I show, in a form, which document that is allready stored in
tblDocuemnt for the user?

Finaly:
- Is there a way to retrive, from the explorer when I store the document
in
my table <tblDocment> the name of the file so I can show that instead of
[Microsoft Word document] or [Microsoft Photo Editor 3.0-foto]. This isn´t
either verry userfriendly?

TIA!
// Niklas
 
Hi Graham!

I have tested with the dialoge box Save/Open as you linked me to. It´s what
I want and I have figure out hiw to store the path but how do I get the
final filename out of it?

This is a little "over my head" even if I have read about API-calls but
never used them.

TIA!
// Niklas


Graham Mandeno said:
Hi Niklas

First, I advise you NOT to try to store the contents of your documents in
the database. This will lead to enormouos database bloat, and will
contribute to the likelihood of corruption.

Instead, store only the path and filename of the document.

To browse for documents, you can use the standard Windows File Open dialog.
There is some code here to do this:
http://www.mvps.org/access/api/api0001.htm

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Niklas Östergren said:
God morning!

I´m about to create a possability for my users to create a msg which have
attachment linked to the msg and then linke the msg to all e-mail address
that the msg (with attachments) have been sent to. So the user can store
every dispatch and se who have recived what and when.

I know that it should be possible to add documents (word documents, Excell
files, pictures etc.) to a table in Access. I have allready created a set
of
tables for storing e-mail message (only the text) and 2 related tables
(one
for storing documents [ActiveX-Object] and one for relate between these
documents and the e-mail msg.).

But how do I do to let the user browse for the files they want to attache
to
the e-mail msg?

I have a form <frmDispatchMsg> (holding the msg) and a subform
<frmsubDispatchMsgDocumentAttachment> (holding the attachments).

From the subform it´s possible to right-click and select
"Attache-document".
But this isn´t verry user friendly since the user then have to select
"Browse" to get to the place I´d like to open up with one mous-click (the
explorer window.

Is there any KB or any place in internet I can read about how to do this?

More specific I´d like to open up the explorer window in which I select
which file (any type) I´d like to store in my table (tblDocument) in a
ActiveX-field.

How to then link this document to the DispatchMsg is easy. But how do I
get
the document in to the table?

Next Q is:
- Since there isn´t any possability (as far as I know of) to open up
either
a combobox or a listbox showing all ActiveX-document stored in
tblDocuemnt.
How do I show, in a form, which document that is allready stored in
tblDocuemnt for the user?

Finaly:
- Is there a way to retrive, from the explorer when I store the document
in
my table <tblDocment> the name of the file so I can show that instead of
[Microsoft Word document] or [Microsoft Photo Editor 3.0-foto]. This isn´t
either verry userfriendly?

TIA!
// Niklas
 
Hi Nicklas

You can use the ShellExecute API to launch the application associated with a
regstered file type. There is some code for you here:
http://www.mvps.org/access/api/api0018.htm

All you need to do is copy and paste the code into a module, save it as
mdlShellExecute, and then call the function, passing the filename and the
type of window you want to open:
Call fHandleFile(txtFileName, WIN_NORMAL)

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Niklas Östergren said:
Hi Graham!

OK, I listen to what you say and I´ll follow your advise.

But I do have some Q about this though!

Is it possible, from storing the path, to open up the document which path
is
stored. Either by a cmd or double_click on the path. Someway to make it
easy
for the user to open the attached file?

Thanks for the advice!

// Niklas


Graham Mandeno said:
Hi Niklas

First, I advise you NOT to try to store the contents of your documents in
the database. This will lead to enormouos database bloat, and will
contribute to the likelihood of corruption.

Instead, store only the path and filename of the document.

To browse for documents, you can use the standard Windows File Open dialog.
There is some code here to do this:
http://www.mvps.org/access/api/api0001.htm

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Niklas Östergren said:
God morning!

I´m about to create a possability for my users to create a msg which have
attachment linked to the msg and then linke the msg to all e-mail address
that the msg (with attachments) have been sent to. So the user can
store
every dispatch and se who have recived what and when.

I know that it should be possible to add documents (word documents, Excell
files, pictures etc.) to a table in Access. I have allready created a set
of
tables for storing e-mail message (only the text) and 2 related tables
(one
for storing documents [ActiveX-Object] and one for relate between these
documents and the e-mail msg.).

But how do I do to let the user browse for the files they want to attache
to
the e-mail msg?

I have a form <frmDispatchMsg> (holding the msg) and a subform
<frmsubDispatchMsgDocumentAttachment> (holding the attachments).

From the subform it´s possible to right-click and select
"Attache-document".
But this isn´t verry user friendly since the user then have to select
"Browse" to get to the place I´d like to open up with one mous-click (the
explorer window.

Is there any KB or any place in internet I can read about how to do this?

More specific I´d like to open up the explorer window in which I select
which file (any type) I´d like to store in my table (tblDocument) in a
ActiveX-field.

How to then link this document to the DispatchMsg is easy. But how do I
get
the document in to the table?

Next Q is:
- Since there isn´t any possability (as far as I know of) to open up
either
a combobox or a listbox showing all ActiveX-document stored in
tblDocuemnt.
How do I show, in a form, which document that is allready stored in
tblDocuemnt for the user?

Finaly:
- Is there a way to retrive, from the explorer when I store the
document
in
my table <tblDocment> the name of the file so I can show that instead
of
[Microsoft Word document] or [Microsoft Photo Editor 3.0-foto]. This isn´t
either verry userfriendly?

TIA!
// Niklas
 
Hi Niklas

I don't really understand your question. The function will return the full
file specification, including the path *and* the filename and extension.
You will need all of this if you want later to launch the file, or attach it
to an email.

Do you mean you want to store the path and the filename in different fields?
If so, then you can use the InStrRev function to find the position of the
*last* backslash in the file spec, then use Left and Mid to extract the
substrings before and after that position.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand



Niklas Östergren said:
Hi Graham!

I have tested with the dialoge box Save/Open as you linked me to. It´s
what
I want and I have figure out hiw to store the path but how do I get the
final filename out of it?

This is a little "over my head" even if I have read about API-calls but
never used them.

TIA!
// Niklas


Graham Mandeno said:
Hi Niklas

First, I advise you NOT to try to store the contents of your documents in
the database. This will lead to enormouos database bloat, and will
contribute to the likelihood of corruption.

Instead, store only the path and filename of the document.

To browse for documents, you can use the standard Windows File Open dialog.
There is some code here to do this:
http://www.mvps.org/access/api/api0001.htm

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Niklas Östergren said:
God morning!

I´m about to create a possability for my users to create a msg which have
attachment linked to the msg and then linke the msg to all e-mail address
that the msg (with attachments) have been sent to. So the user can
store
every dispatch and se who have recived what and when.

I know that it should be possible to add documents (word documents, Excell
files, pictures etc.) to a table in Access. I have allready created a set
of
tables for storing e-mail message (only the text) and 2 related tables
(one
for storing documents [ActiveX-Object] and one for relate between these
documents and the e-mail msg.).

But how do I do to let the user browse for the files they want to attache
to
the e-mail msg?

I have a form <frmDispatchMsg> (holding the msg) and a subform
<frmsubDispatchMsgDocumentAttachment> (holding the attachments).

From the subform it´s possible to right-click and select
"Attache-document".
But this isn´t verry user friendly since the user then have to select
"Browse" to get to the place I´d like to open up with one mous-click (the
explorer window.

Is there any KB or any place in internet I can read about how to do this?

More specific I´d like to open up the explorer window in which I select
which file (any type) I´d like to store in my table (tblDocument) in a
ActiveX-field.

How to then link this document to the DispatchMsg is easy. But how do I
get
the document in to the table?

Next Q is:
- Since there isn´t any possability (as far as I know of) to open up
either
a combobox or a listbox showing all ActiveX-document stored in
tblDocuemnt.
How do I show, in a form, which document that is allready stored in
tblDocuemnt for the user?

Finaly:
- Is there a way to retrive, from the explorer when I store the
document
in
my table <tblDocment> the name of the file so I can show that instead
of
[Microsoft Word document] or [Microsoft Photo Editor 3.0-foto]. This isn´t
either verry userfriendly?

TIA!
// Niklas
 
THANK´s a lot Graham!

This realy make this part of the application much more user friendly! And it
was way over my head. So no way I could have fixed this myself!

I have read about API calls and how to use dll´s. But never dared to try it
out. When I have time I´ll look closer into this code because I´d like to
know why it work´s and what it´s doing. Since I´d like to learn more!

Thank´s again Graham!

// Niklas


Graham Mandeno said:
Hi Nicklas

You can use the ShellExecute API to launch the application associated with a
regstered file type. There is some code for you here:
http://www.mvps.org/access/api/api0018.htm

All you need to do is copy and paste the code into a module, save it as
mdlShellExecute, and then call the function, passing the filename and the
type of window you want to open:
Call fHandleFile(txtFileName, WIN_NORMAL)

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Niklas Östergren said:
Hi Graham!

OK, I listen to what you say and I´ll follow your advise.

But I do have some Q about this though!

Is it possible, from storing the path, to open up the document which path
is
stored. Either by a cmd or double_click on the path. Someway to make it
easy
for the user to open the attached file?

Thanks for the advice!

// Niklas


Graham Mandeno said:
Hi Niklas

First, I advise you NOT to try to store the contents of your documents in
the database. This will lead to enormouos database bloat, and will
contribute to the likelihood of corruption.

Instead, store only the path and filename of the document.

To browse for documents, you can use the standard Windows File Open dialog.
There is some code here to do this:
http://www.mvps.org/access/api/api0001.htm

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

God morning!

I´m about to create a possability for my users to create a msg which have
attachment linked to the msg and then linke the msg to all e-mail address
that the msg (with attachments) have been sent to. So the user can
store
every dispatch and se who have recived what and when.

I know that it should be possible to add documents (word documents, Excell
files, pictures etc.) to a table in Access. I have allready created a set
of
tables for storing e-mail message (only the text) and 2 related tables
(one
for storing documents [ActiveX-Object] and one for relate between these
documents and the e-mail msg.).

But how do I do to let the user browse for the files they want to attache
to
the e-mail msg?

I have a form <frmDispatchMsg> (holding the msg) and a subform
<frmsubDispatchMsgDocumentAttachment> (holding the attachments).

From the subform it´s possible to right-click and select
"Attache-document".
But this isn´t verry user friendly since the user then have to select
"Browse" to get to the place I´d like to open up with one mous-click (the
explorer window.

Is there any KB or any place in internet I can read about how to do this?

More specific I´d like to open up the explorer window in which I select
which file (any type) I´d like to store in my table (tblDocument) in a
ActiveX-field.

How to then link this document to the DispatchMsg is easy. But how do I
get
the document in to the table?

Next Q is:
- Since there isn´t any possability (as far as I know of) to open up
either
a combobox or a listbox showing all ActiveX-document stored in
tblDocuemnt.
How do I show, in a form, which document that is allready stored in
tblDocuemnt for the user?

Finaly:
- Is there a way to retrive, from the explorer when I store the
document
in
my table <tblDocment> the name of the file so I can show that instead
of
[Microsoft Word document] or [Microsoft Photo Editor 3.0-foto]. This isn´t
either verry userfriendly?

TIA!
// Niklas
 
You did understand me correct!

Well, I don´t realy need to STORE the filename in a seperat field, since I
allready have it in the path (returned by the procedure). But I´d like to
somehow show only the file name to the user and to be able to check if the
file name allready exist in the db.

You see the assosiation that I´m doing this application for don´t realy have
so good order on theire network so a file exist in differnet places with
exactly the same name and content´s. And I´d like to check this before I
save the path to a file and if allready saved in the db then display a msg
and maby highlight the path stored in the db.

Besides it´s much easyer for the user to read only the file name then the
whole path if they are searching for stored file names.

Why all this work you may ask?

Well the thing is that the user´s want to store every dispatch completly in
the db so it´s easy for them to se IF they have sent the msg and what was in
the msg sent to whom. And the, offcourse, only want to store the e-mail
addresses in ONE place. The way it is today they have two places. The old
member register, which I´m now developing a new one for them, and also in
Microsoft Outlook Express. So they have two places where they need to change
or delete or add a e-mail address.

The last bit of this could be done without me saving the path to attached
files letting the user need to open Outlook Express to find out which
members have recived which dispatches. And maby this isn´t realy neccesary
what I´m doing right now. I don´t know. The only thing I know is that I
learn from it and I don´t have any time pressure on me so I´m happy :-)

What I mean is that I could have let it be with just storing the e-mail
addresses and starting a new e-mail msg and hand over the e-mail addresses
and leave it there (from my point of view). The rest of it will then, no
matter what I do in the application, be stored in Outlook Express. It´s just
that the user would have to search for a dispatch there instead of in my
application.

Like I said! I learn a lot from doing different things, even if I know that
I have to be better on doing things more efficent, but so fare I´m happy if
I kan learn new ways of using different technices, which I do.

Thank´s for all help Graham. I want you to know that I realy appreciate it!

// Niklas

Graham Mandeno said:
Hi Niklas

I don't really understand your question. The function will return the full
file specification, including the path *and* the filename and extension.
You will need all of this if you want later to launch the file, or attach it
to an email.

Do you mean you want to store the path and the filename in different fields?
If so, then you can use the InStrRev function to find the position of the
*last* backslash in the file spec, then use Left and Mid to extract the
substrings before and after that position.
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand



Niklas Östergren said:
Hi Graham!

I have tested with the dialoge box Save/Open as you linked me to. It´s
what
I want and I have figure out hiw to store the path but how do I get the
final filename out of it?

This is a little "over my head" even if I have read about API-calls but
never used them.

TIA!
// Niklas


Graham Mandeno said:
Hi Niklas

First, I advise you NOT to try to store the contents of your documents in
the database. This will lead to enormouos database bloat, and will
contribute to the likelihood of corruption.

Instead, store only the path and filename of the document.

To browse for documents, you can use the standard Windows File Open dialog.
There is some code here to do this:
http://www.mvps.org/access/api/api0001.htm

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

God morning!

I´m about to create a possability for my users to create a msg which have
attachment linked to the msg and then linke the msg to all e-mail address
that the msg (with attachments) have been sent to. So the user can
store
every dispatch and se who have recived what and when.

I know that it should be possible to add documents (word documents, Excell
files, pictures etc.) to a table in Access. I have allready created a set
of
tables for storing e-mail message (only the text) and 2 related tables
(one
for storing documents [ActiveX-Object] and one for relate between these
documents and the e-mail msg.).

But how do I do to let the user browse for the files they want to attache
to
the e-mail msg?

I have a form <frmDispatchMsg> (holding the msg) and a subform
<frmsubDispatchMsgDocumentAttachment> (holding the attachments).

From the subform it´s possible to right-click and select
"Attache-document".
But this isn´t verry user friendly since the user then have to select
"Browse" to get to the place I´d like to open up with one mous-click (the
explorer window.

Is there any KB or any place in internet I can read about how to do this?

More specific I´d like to open up the explorer window in which I select
which file (any type) I´d like to store in my table (tblDocument) in a
ActiveX-field.

How to then link this document to the DispatchMsg is easy. But how do I
get
the document in to the table?

Next Q is:
- Since there isn´t any possability (as far as I know of) to open up
either
a combobox or a listbox showing all ActiveX-document stored in
tblDocuemnt.
How do I show, in a form, which document that is allready stored in
tblDocuemnt for the user?

Finaly:
- Is there a way to retrive, from the explorer when I store the
document
in
my table <tblDocment> the name of the file so I can show that instead
of
[Microsoft Word document] or [Microsoft Photo Editor 3.0-foto]. This isn´t
either verry userfriendly?

TIA!
// Niklas
 
Back
Top