Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How to load a PDF using Excel VBA? Can anyone give sample code
Many thanks in advance! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
what do you mean with 'load PDF'. Note: Its not so easy to convert a PDF document back to an Excel file format (has nothing to do with VBA) -- Regards Frank Kabel Frankfurt, Germany James wrote: How to load a PDF using Excel VBA? Can anyone give sample code? Many thanks in advance! |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I mean, I got a PDF file. I want to use Excel VBA to open that PDF in Acrobat Reader. Just like when you double-click a PDF using the mouse
|
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I tried before I submit the question. Failed
But thanks anyway. : ----- Dave Peterson wrote: ---- Ahhh maybe something like Shell "start myfile.pdf James wrote I want to open the PDF in Acrobat Reader, not importing it into Excel. But use Excel VBA ----- Dave Peterson wrote: ---- You could search google for pdf translators (to excel or to text files). Mos are commercial ($) You might get lucky and be able to copy each column and paste into excel (colum by column)--from Adobe Reader James wrote I mean, I got a PDF file. I want to use Excel VBA to open that PDF in Acrobat Reader. Just like when you double-click a PDF using the mouse - Dave Peterso -- Dave Peterso |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I could not get this to work until I included the full path and name of the
Adobe Acrobat reader in the command along with the desired file name. Apparently, Shell passes the whole string directly to the command engine without looking up the association in the registry. This could be a problem if you are going to try to run this on a variety of machines, since the Adobe Reader may be in different subdirectories on every machine. Shell "C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe C:\My Documents\Test Page.pdf", _ vbNormalFocus (You can replace the vbNormalFocus with vbMaximizedFocus or whatever value you want for the window style.) -- Regards, Bill "James" wrote in message ... I tried before I submit the question. Failed. But thanks anyway. : ----- Dave Peterson wrote: ----- Ahhh. maybe something like: Shell "start myfile.pdf" James wrote: I want to open the PDF in Acrobat Reader, not importing it into Excel. But use Excel VBA. ----- Dave Peterson wrote: ----- You could search google for pdf translators (to excel or to text files). Most are commercial ($). You might get lucky and be able to copy each column and paste into excel (column by column)--from Adobe Reader. James wrote: I mean, I got a PDF file. I want to use Excel VBA to open that PDF in Acrobat Reader. Just like when you double-click a PDF using the mouse. -- Dave Peterson -- Dave Peterson |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi James
o.k. that's simple :-) have a look at the VBA Shell method. e.g. Shell "mypdffile.pdf" -- Regards Frank Kabel Frankfurt, Germany James wrote: I mean, I got a PDF file. I want to use Excel VBA to open that PDF in Acrobat Reader. Just like when you double-click a PDF using the mouse. |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
"Frank Kabel" wrote:
<<Shell "mypdffile.pdf" Does this really work on your machine? I had trouble with this (Win ME and Excel 2000 SP-3). (See my post about an hour before yours.) (Need to resynchronize your newsreader every 15 minutes or so?) -- Regards, Bill |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Chip Pearson posted an API solution to find the executable (modified very
slightly for pdf): Option Explicit 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 Declare Function FindExecutable Lib "shell32.dll" _ Alias "FindExecutableA" ( _ ByVal lpFile As String, _ ByVal lpDirectory As String, _ ByVal lpResult As String) As Long Sub AAA() Dim FName As String Dim FNum As String Dim ExeName As String Dim Res As Long FName = String$(255, " ") ExeName = String$(255, " ") Res = GetTempFileName(CurDir, "", 0&, FName) FName = Application.Trim(FName) Mid$(FName, Len(FName) - 2, 3) = "pdf" FNum = FreeFile Open FName For Output As #FNum Close #FNum Res = FindExecutable(FName, vbNullString, ExeName) Kill FName If Res 32 Then ' association found ExeName = Left$(ExeName, InStr(ExeName, Chr(0)) - 1) Else ' no association found ExeName = "" End If MsgBox ExeName End Sub Bill Renaud wrote: I could not get this to work until I included the full path and name of the Adobe Acrobat reader in the command along with the desired file name. Apparently, Shell passes the whole string directly to the command engine without looking up the association in the registry. This could be a problem if you are going to try to run this on a variety of machines, since the Adobe Reader may be in different subdirectories on every machine. Shell "C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe C:\My Documents\Test Page.pdf", _ vbNormalFocus (You can replace the vbNormalFocus with vbMaximizedFocus or whatever value you want for the window style.) -- Regards, Bill "James" wrote in message ... I tried before I submit the question. Failed. But thanks anyway. : ----- Dave Peterson wrote: ----- Ahhh. maybe something like: Shell "start myfile.pdf" James wrote: I want to open the PDF in Acrobat Reader, not importing it into Excel. But use Excel VBA. ----- Dave Peterson wrote: ----- You could search google for pdf translators (to excel or to text files). Most are commercial ($). You might get lucky and be able to copy each column and paste into excel (column by column)--from Adobe Reader. James wrote: I mean, I got a PDF file. I want to use Excel VBA to open that PDF in Acrobat Reader. Just like when you double-click a PDF using the mouse. -- Dave Peterson -- Dave Peterson -- Dave Peterson |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Are you sure that the pc has Reader installed?
Another option (also worked for me): ActiveWorkbook.FollowHyperlink "c:\myfolder\myfile.pdf" (Did you include the complete path when you tested the Start suggestion?) James wrote: I tried before I submit the question. Failed. But thanks anyway. : ----- Dave Peterson wrote: ----- Ahhh. maybe something like: Shell "start myfile.pdf" James wrote: I want to open the PDF in Acrobat Reader, not importing it into Excel. But use Excel VBA. ----- Dave Peterson wrote: ----- You could search google for pdf translators (to excel or to text files). Most are commercial ($). You might get lucky and be able to copy each column and paste into excel (column by column)--from Adobe Reader. James wrote: I mean, I got a PDF file. I want to use Excel VBA to open that PDF in Acrobat Reader. Just like when you double-click a PDF using the mouse. -- Dave Peterson -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
HELP!!!! New PC and can't load excel | Setting up and Configuration of Excel | |||
how do i load excel | Setting up and Configuration of Excel | |||
Excel won't load | Excel Discussion (Misc queries) | |||
Excel XP will not load | Setting up and Configuration of Excel | |||
How to use Excel C API to load an XLL add-in? | Excel Programming |