Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > microsoft.public.excel.programming > #109745

Re: close a pdf file opened via shellexecute

From GS <gs@v.invalid>
Newsgroups microsoft.public.excel.programming
Subject Re: close a pdf file opened via shellexecute
Date 2016-12-09 20:42 -0500
Organization A noiseless patient Spider
Message-ID <o2fmg1$unr$1@dont-email.me> (permalink)
References <96a5abdc-d536-4116-bf7f-ce65654cea98@googlegroups.com>

Show all headers | View raw


> I am using the following code to open a pdf file. 
>
> Private Declare Function ShellExecute Lib "shell32.dll" 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
>
> strFile = 'assume strFile is opening without issue
>
>     ShellExecute 0, "open", strFile, vbNullString, vbNullString, 0
>
>
>
> how can I close the PDF file with vba script? Thank you in advance!

You need to know the name of the app that opens PDFs, and determine 
what its window 'title' is so you can grab its 'handle'. Once done you 
can send it a close message. You could simple query open windows for 
determining which has the filename in its 'title'; -obviates needing to 
know which app opens PDFs on another machine if your project runs 
there.

I have code that runs an out-of-process EXE as though it was 
in-process. It locates the window and grabs its handle so that EXE ends 
when my project shuts down. I can dig for the exact code and post 
back...

-- 
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
  comp.lang.basic.visual.misc
  microsoft.public.vb.general.discussion

Back to microsoft.public.excel.programming | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

close a pdf file opened via shellexecute Matthew Dyer <matthew.e.dyer@gmail.com> - 2016-12-09 13:58 -0800
  Re: close a pdf file opened via shellexecute GS <gs@v.invalid> - 2016-12-09 20:42 -0500
    Re: close a pdf file opened via shellexecute GS <gs@v.invalid> - 2016-12-09 21:11 -0500
      Re: close a pdf file opened via shellexecute Matthew Dyer <matthew.e.dyer@gmail.com> - 2016-12-09 22:01 -0800
        Re: close a pdf file opened via shellexecute GS <gs@v.invalid> - 2016-12-10 01:07 -0500

csiph-web