Rabu, 08 Agustus 2012

Re: [MS_AccessPros] Re: Opening Documents in Access

 

John
 
Thank you that worked. Here is the final code.
 
 If Not IsNull(Me.DocumentPath) Then
     'If path already exists in the DocumentPath field use it
     Application.FollowHyperlink Me.DocumentPath
  Else
    Application.FollowHyperlink strFile_Path
  End If
 
This is the Browse Function
 
Function BrowseToFile()
On Error GoTo BrowseToFile_Err
'Prompt user for file path
Application.FileDialog(msoFileDialogOpen).Show
strFile_Path = Application.FileDialog(msoFileDialogOpen).SelectedItems.Item(1)

BrowseToFile_Exit:
    Exit Function
BrowseToFile_Err:
    MsgBox Error$
    Resume BrowseToFile_Exit
End Function
 
Private Sub cmdBrowse_Click()
  Call BrowseToFile
  Me.DocumentPath = strFile_Path

End Sub

With warm regards,

Arthur Lorenzini
Sioux Falls, South Dakota

________________________________
From: John Viescas <JohnV@msn.com>
To: MS_Access_Professionals@yahoogroups.com
Sent: Wednesday, August 8, 2012 11:33 AM
Subject: RE: [MS_AccessPros] Re: Opening Documents in Access


 

Art-

If you have a good path to the file, the "cheap and easy" way to open the file is:

Application.FollowHyperlink strFile

John Viescas, author
Microsoft Office Access 2010 Inside Out
Microsoft Office Access 2007 Inside Out
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)

-----Original Message-----
From: mailto:MS_Access_Professionals%40yahoogroups.com [mailto:mailto:MS_Access_Professionals%40yahoogroups.com] On Behalf Of Art Lorenzini
Sent: Wednesday, August 08, 2012 6:16 PM
To: mailto:MS_Access_Professionals%40yahoogroups.com
Subject: Re: [MS_AccessPros] Re: Opening Documents in Access

Bill,
I figured out how to get my file dialog open and pass the path to my field. It is being held in a public variable called strFile_Path. Now how do I pass that into your function to view the file?

With warm regards,

Arthur Lorenzini
Sioux Falls, South Dakota

________________________________
From: Bill Mosca <mailto:wrmosca%40comcast.net>
To: mailto:MS_Access_Professionals%40yahoogroups.com
Sent: Wednesday, August 8, 2012 10:06 AM
Subject: [MS_AccessPros] Re: Opening Documents in Access

Art

I use the Scripting Shell function to open external files.

Public Function ScriptShell(strfile As String)
'Purpose : Use instead of Shell().
' Works for shortcuts, too.
'DateTime : 9/28/2007 11:28
'Author : Bill Mosca
'Reference: http://msdn2.microsoft.com/en-us/library/d5fk67ky.aspx
'WScript.Shell object's arguments:
' object.Run(strCommand, [intWindowStyle], [bWaitOnReturn])
'
' [intWindowStyle]:
' 0 Hides the window and activates another window.
' 1 Activates and displays a window. If the window is minimized
' or maximized, the system restores it to its original size
' and position. An application should specify this flag when
' displaying the window for the first time.
' 2 Activates the window and displays it as a minimized window.
' 3 Activates the window and displays it as a maximized window.
' 4 Displays a window in its most recent size and position.
' The active window remains active.
' [bWaitOnReturn]: boolean
Dim WshShell As Object

'VBScript
'Set WshShell = WScript.CreateObject("WScript.Shell")

Set WshShell = CreateObject("WScript.Shell")

'Shortcut example
'WshShell.Run "C:\FRS3000\StartFRS3000.lnk"

WshShell.Run strfile

Set WshShell = Nothing

End Function

Regards,
Bill Mosca, Founder - MS_Access_Professionals
http://www.thatlldoit.com
Microsoft Office Access MVP
https://mvp.support.microsoft.com/profile=C4D9F5E7-BB03-4291-B816-64270730881E
My nothing-to-do-with-Access blog
http://wrmosca.wordpress.com

--- In mailto:MS_Access_Professionals%40yahoogroups.com, "Art" <dbalorenzini@...> wrote:
>
> I am designing a document subform called sfmRoofDocuments. It will be a continous form based on the following table structure:
>
> RoofDocumentID - auto number
> InspectionID - Number
> DocumentTypeID - Number
> DocumentTitle - Text
> DocumentPath - Text
> Comments - Memo
>
> For each record I would like to add a two buttons, one to browse to where the file is located and one to view the file. So if the file happens to be a Word file then it would open up in Word, or Excel or if it is an image a Photo Editor. Is there some example code or anyone with any ideas on how I can get this implemented.
>
> Thank you
>
> Arthur Lorenzini
> Sioux Falls, SD
>

[Non-text portions of this message have been removed]

------------------------------------

Yahoo! Groups Links

[Non-text portions of this message have been removed]

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar