Andy Lacey
andy at minstersystems.co.uk
Wed Jun 25 07:46:41 CDT 2008
Hi Tina Effectively it does what Windows does if you double-click on a file in Explorer, ie uses the rergistered app for that file type to open the file. It's no use if you want to manipulate the file via, say, the Word object model, but great if all you want to do is open it. -- Andy Lacey http://www.minstersystems.co.uk --------- Original Message -------- From: "Access Developers discussion and problem solving" <accessd at databaseadvisors.com> To: "Access Developers discussion and problem solving" <accessd at databaseadvisors.com> Subject: Re: [AccessD] How to get my Word document open Date: 25/06/08 11:16 Hi Andy, Many thanks for this. There's a lot here, so I'm digesting it still, but my understanding is that this function checks for all the things that might interfere with opening the target file, and if everything is okay the file will open. Terrific! Tina Andy Lacey wrote: > Hi Tina > My suggestion is to create a module and put this RunApp function in it > > -------------------------------------------------- > Declare Function ShellExecute Lib "shell32" Alias "ShellExecuteA" (ByVal > hWnd As Long, _ > ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As > String, _ > ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long > > Function RunApp(strFile As String, bytSize) As Boolean > Dim lngRet As Long > Dim varTaskID As Variant > Dim strRet As String > > lngRet = ShellExecute(hWndAccessApp, vbNullString, strFile, > vbNullString, vbNullString, bytSize) > If lngRet > Success Then > strRet = vbNullString > lngRet = -1 > RunApp = True > Else > RunApp = False > Select Case lngRet > Case NotRegistered > varTaskID = Shell("rundll32.exe shell32.dll,OpenAs_RunDLL " > & strFile, bytSize) > lngRet = (varTaskID <> 0) > Case InadequateMemory > MsgBox "Error: Out of Memory/Resources!" > Case FileNotFound > MsgBox "Error: File not found!" > Case PathNotFound > MsgBox "Error: Path not found!" > Case BadFormat > MsgBox "Error: Bad File Format!" > Case 5 > MsgBox "Error: Unauthorized due to Security restrictions!" > End Select > End If > End Function > ------------------------------------------------ > > Then you can open a Word doc, an Excel sheet, a PDF or anything else just by > a simple call to that, ie > > Call RunApp("C:WhereverWhatever.doc", 1) > > > -- Andy Lacey > http://www.minstersystems.co.uk > > >> -----Original Message----- >> From: accessd-bounces at databaseadvisors.com >> [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of >> Tina Norris Fields >> Sent: 24 June 2008 23:11 >> To: AccessD at databaseadvisors.com >> Subject: [AccessD] How to get my Word document open >> >> >> Hi Group, >> >> Again, I know I've seen something on this before, but what >> I've found so >> far doesn't quite work, so I'm looking for help. >> >> On my form, I have a nice button that will launch Word for me, but I >> want it to open a particular document. The things I have tried so far >> are not working. So, once again I turn to this knowledgeable >> group for >> assistance. How do I make Access launch Word and open a >> specific document? >> >> Thanks for your help, >> Tina >> -- >> AccessD mailing list >> AccessD at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/accessd >> Website: http://www.databaseadvisors.com >> >> >> > > > > -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com ________________________________________________ Message sent using UebiMiau 2.7.2