Consulting

Results 1 to 2 of 2

Thread: Copying from a PDF file

  1. #1
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location

    Copying from a PDF file

    I have two codes, the first works, but produces a warning I can't find a way to eliminate.
    The second gives no warning, but instead of copying the pdf contents, it copies the Sendkeys code and pastes it into my document.

    The Send Keys code sends
    Edit/Select All
    Edit/Copy
    Close

    Any thoughts?

    [VBA]
    Sub OpenPDF(init As Range)
    ActiveWorkbook.FollowHyperlink "S:\TimeSheets\" & init.Value & ".pdf"
    With Application
    .SendKeys ("%e"), True
    .SendKeys ("a"), True
    .SendKeys ("%e"), True
    .SendKeys ("c"), True
    .SendKeys ("%{F4}"), True
    End With
    End Sub

    Sub StartPDFFile(init As Range)
    Dim objWSH As Object
    Set objWSH = CreateObject("WScript.Shell")
    objWSH.Run Chr(34) & "S:\TimeSheets\" & init.Value & ".pdf" & Chr(34)
    With Application
    .SendKeys ("%e"), True
    .SendKeys ("a"), True
    .SendKeys ("%e"), True
    .SendKeys ("c"), True
    .SendKeys ("%{F4}"), True
    End With
    End Sub

    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  2. #2
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Issue resolved, but I'm not clear why. After using the second code, the first then also failed. Building in delays showed that instead of sending "a", I needed to send "l", It seems a different Reader is opening, with a slightly different menu.

    Now I just need to figure out how to cater for both options!
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •