Hi,
Thanks a lot for all your responses.
I used just this command, this opens the acrobat and
this pdf.
Call ShellExecute(0&, "open", App.path & "\temp1.pdf",
0&, 0&, SW_SHOWNORMAL)
When i tried shell(app.path & "\temp1.pdf") it didn't
work (for me).
After all these responses, i kind of feeling that the
way i did is wrong (or not right), is it so? I thought
it does and simple enough.
Thanks.
--- Satyajeet Hattangadi <satyajh@m...>
wrote:
>
> Hi,
>
> Finding the Associated Program...
>
> Just pass it the extension - such as TXT or PDF in
> your case - and it'll
> return the associated Windows program.
>
> It works by using the FindExecutable API call to
> locate the executable.
> However this requires an actual file with the
> requested extension, which is
> created with another couple of calls. The temporary
> file is deleted after
> the process has finished.
>
> To use this code, call GetAssociatedExecutable,
> passing in the extension as
> a string.
>
> Usage
>
> x = GetAssociatedExecutable("PDF")
>
> here x will hold path of acroread, then its a simple
> matter of using
> shellexecute and waitforsingleobject
>
> HTH
> Satya
>
> Code
>
> Private Declare Function FindExecutable Lib _
> "shell32.dll" Alias "FindExecutableA" _
> (ByVal lpFile As String, ByVal lpDirectory _
> As String, ByVal lpResult As String) As Long
>
> Private Declare Function GetTempFileName Lib _
> "kernel32" Alias "GetTempFileNameA" (ByVal _
> lpszPath As String, ByVal lpPrefixString _
> As String, ByVal wUnique As Long, ByVal _
> lpTempFileName As String) As Long
>
> Private Declare Function GetTempPath Lib _
> "kernel32" Alias "GetTempPathA" (ByVal _
> nBufferLength As Long, ByVal lpBuffer As _
> String) As Long
>
> Public Function GetAssociatedExecutable(ByVal _
> Extension As String) As String
>
> Dim Path As String
> Dim FileName As String
> Dim nRet As Long
> Const MAX_PATH As Long = 260
>
> 'Create a tempfile
> Path = String$(MAX_PATH, 0)
>
> If GetTempPath(MAX_PATH, Path) Then
> FileName = String$(MAX_PATH, 0)
>
> If GetTempFileName(Path, "~", 0, FileName)
> Then
> FileName = Left$(FileName, _
> InStr(FileName, vbNullChar) - 1)
>
> 'Rename it to use supplied extension
> Name FileName As Left$(FileName, _
> InStr(FileName, ".")) & Extension
> FileName = Left$(FileName, _
> InStr(FileName, ".")) & Extension
>
> 'Get name of associated EXE
> Path = String$(MAX_PATH, 0)
>
> Call FindExecutable(FileName, _
> vbNullString, Path)
> GetAssociatedExecutable = Left$( _
> Path, InStr(Path, vbNullChar) - 1)
>
> 'Clean up
> Kill FileName
>
> End If
>
> End If
>
> End Function
>
> ----- Original Message -----
> From: "Stuart Naylor" <indtec@e...>
> To: "professional vb" <pro_vb@p...>
> Sent: Friday, March 14, 2003 3:50 PM
> Subject: [pro_vb] RE: Execute a pdf file
>
> > Yes there is a sample for acrobat that can check
> the registry for the
> > install path. Then you excute a shell command to
> the document
> > Check the adobe developer samples for Vb as the
> registry infomation is
> there
> > apart from AcroRd32.exe if you check the registry
> there is a path entry
> for
> > its location.
> > You can also do a very small amount of DDE but it
> is crap but there are
> > samples on the Acrobat developer site.
> > Personally I think it is crap how the dont release
> an API for reader.
> > If ya want a viewer then exploder can be a viable
> alternative to control,
> if
> > ya deal with a beast, deal with a single one?
> >
> >
> >
> > -----Original Message-----
> > From: Ramesh Sridharan
> [mailto:mr_sriramesh@y...]
> > Sent: 13 March 2003 20:47
> > To: professional vb
> > Subject: [pro_vb] Execute a pdf file
> >
> >
> > hi,
> > I want to execute a pdf file from the VB
> > application, but i don't know the location of
> > acroread.exe. can i tackle this situation?
> >
> > Thanks.
> >
> > =====
> > Sincerely,
> > Ramesh S ( Ph: xxx-xxx-xxxx )
> >
> > __________________________________________________
> > Do you Yahoo!?
> > Yahoo! Web Hosting - establish your business
> online
> > http://webhosting.yahoo.com
> >
> >
> >
> >
>
>
*********************************************************
> Disclaimer
>
> This message (including any attachments) contains
> confidential information intended for a specific
> individual and purpose, and is protected by law.
> If you are not the intended recipient, you should
> delete this message and are hereby notified that
> any disclosure, copying, or distribution of this
> message, or the taking of any action based on it,
> is strictly prohibited.
>
>
*********************************************************
> Visit us at http://www.mahindrabt.com
>
>
>
>
=====
Sincerely,
Ramesh S ( Ph: xxx-xxx-xxxx )
__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - establish your business online
http://webhosting.yahoo.com