I need form that will give users access to word docs.

I need form that will give users access to word docs.

Post by Douglas J. » Fri, 19 Jan 2007 21:08:09


http://www.yqcomputer.com/ "The Access Web" will show you
how to allow the users to select a file (or files).

Once you know which file they want to open, use Application.FollowHyperlink
to open it.

--
Doug Steele, Microsoft Access MVP
http://www.yqcomputer.com/
(no e-mails, please!)
 
 
 

I need form that will give users access to word docs.

Post by Douglas J. » Fri, 19 Jan 2007 23:00:37

Create a new module. Copy everything from the shaded section (between the
Code Start and Code End) and paste it into that module. Save the module
(making sure you don't name it the same as any of the routines in it.)

When you want to use it, use code like the 4 lines at the beginning of the
page (that example limits the input to Excel files only). For other
examples, see the TestIt and GetOpenFile functions included in what you
copied into the module.

--
Doug Steele, Microsoft Access MVP
http://www.yqcomputer.com/
(no e-mails, please!)

 
 
 

I need form that will give users access to word docs.

Post by Douglas J. » Fri, 19 Jan 2007 23:45:46

Wow. Surprising I'm not being hit by that, given how overly paranoid we are
about security!

Another approach is to use Automation.

Instantiated an instance of the Word application, then open the file:

Dim objWord As Object

Set objWord = CreateObject("Word.Application")
objWord.Documents.Open "C:\Folder\File.doc"
objWord.Visible = True


--
Doug Steele, Microsoft Access MVP
http://www.yqcomputer.com/
(no e-mails, please!)
 
 
 

I need form that will give users access to word docs.

Post by c2N1YmFkaX » Fri, 19 Jan 2007 23:50:03


I want to restrict it to word documents. I have changed the code at the top
of the page to the following:

Dim strFilter As String
Dim strInputFileName as string

strFilter = ahtAddFilterItem(strFilter, "Word Files (*.DOC)", "*.DOC")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)

Where do I put these four lines? Also is it possible to adapt the code so
that, When the dialog box is opened, it goes straight to a specific folder
(Rather than just "my documents").

Thanks
 
 
 

I need form that will give users access to word docs.

Post by Douglas J. » Sat, 20 Jan 2007 00:00:28

ut those lines of code wherever you want them invoked! For example, if you
want them to click on a button to invoke the dialog, put that code in the
Click event of the button.

To start in a specific folder, pass the function a value for InitialDir:

strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
InitialDir:="C:\SomeFolder\", _
Flags:=ahtOFN_HIDEREADONLY)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"scubadiver" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...


 
 
 

I need form that will give users access to word docs.

Post by c2N1YmFkaX » Sat, 20 Jan 2007 00:20:03

've got that worked out but where do I put

application.followhyperlink

thanks for your help

"Douglas J. Steele" wrote:

 
 
 

I need form that will give users access to word docs.

Post by Douglas J. » Sat, 20 Jan 2007 00:47:40

f you want to open the file as soon as they've selected it, put

If Len(Dir(strInputFileName)) > 0 Then
Application.FollowHyperlink strInputFileName
End If

right after the

strInputFileName = aht(CommonFileOpenSave(...)

If you're saving their selected files in a table, and then letting them
select from that table, put it in the appropriate event once they've
selected it.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"scubadiver" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...


 
 
 

I need form that will give users access to word docs.

Post by S2xhdHV » Sat, 20 Jan 2007 00:48:00

I am at a very large defense contractor. We have security people who watch
the security people :)
--
Dave Hargis, Microsoft Access MVP
 
 
 

I need form that will give users access to word docs.

Post by c2N1YmFkaX » Sat, 20 Jan 2007 01:14:01

Like this?

strInputFileName = ahtCommonFileOpenSave( _
If Len(Dir(strInputFileName)) > 0 Then
Application.FollowHyperlink strInputFileName
End If
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
InitialDir:="C:\SomeFolder\", _
Flags:=ahtOFN_HIDEREADONLY)

I get compile errors.



"Douglas J. Steele" wrote:

 
 
 

I need form that will give users access to word docs.

Post by Douglas J. » Sat, 20 Jan 2007 06:20:43

o.

Like

Dim strFilter As String
Dim strInputFileName as string

strFilter = ahtAddFilterItem(strFilter, "Word Files (*.DOC)", "*.DOC")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)
Application.FollowHyperlink strInputFile

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"scubadiver" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...


 
 
 

I need form that will give users access to word docs.

Post by c2N1YmFkaX » Sun, 21 Jan 2007 05:35:00

select a file and press "open" but nothing happens


"Douglas J. Steele" wrote:

 
 
 

I need form that will give users access to word docs.

Post by Douglas J. » Sun, 21 Jan 2007 05:54:11

ut a break point in your code, and make sure that strInputFile contains the
full path to the file.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"scubadiver" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...


 
 
 

I need form that will give users access to word docs.

Post by c2N1YmFkaX » Tue, 23 Jan 2007 18:42:01

hanks for the reply. This kind of VBA is new to me.

I inserted the break point over the last line

"Application.FollowHyperlink strInputFile"

When I click on the "open" box, it goes straight to the VBA??

"Douglas J. Steele" wrote:

 
 
 

I need form that will give users access to word docs.

Post by Douglas J. » Tue, 23 Jan 2007 20:15:08

hat's correct: a breakpoint will take you to the appropriate point in the
code, and halt execution.

At that point, you can go to the Immediate Window, type

?strInputFile

(complete with the question mark) and hit Enter. The value of strInputFile
will be printed directly below what you typed. (You could also hover your
mouse over the variable name in the code window, and the value should be
shown. The advantage of doing it in the Immediate Window is that you can see
the whole value, and you can copy it into a reply)

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"scubadiver" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...


 
 
 

I need form that will give users access to word docs.

Post by c2N1YmFkaX » Tue, 23 Jan 2007 20:26:03

hanks for that but I haven't explained too well.

In the code, I am not opening a specific file. When the dialog box is open
it goes to a folder where the user will click on one of three folders and
then they will open the word document. Does this make things a bit more
difficult?


"Douglas J. Steele" wrote: