+ Reply to Thread
Results 1 to 9 of 9

Macro Button To open PDF File

  1. #1
    Forum Contributor
    Join Date
    02-05-2008
    Posts
    116

    Macro Button To open PDF File

    Hi

    Im wondering If anyone can help me solve a problem, I have a workbook that has hundreds of part numbers in column A. I want to create code that I can insert into a macro button which I can copy and past into a button on each corresponding row say in column E that will look to the A column see the number given and then search a folder where all the pdf files are kept and search for the number (The pdf's are saved as the numbers) open it then print it

    Is that possible??

    Many Thanks

    Denzil

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Denzil,

    Here is macro to print all files of the same type in a folder. Now all we need to do is figure out to use it in your workbook. Can you post what you have so I can review it?

    Macro to Print All Files in a Directory of the Same Type
    Please Login or Register  to view this content.
    Calling the Macro
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  3. #3
    Forum Contributor
    Join Date
    02-05-2008
    Posts
    116
    Hi Leith

    Sorry for the delay! many thanks for the response

    Ive attached a sample, if the code could be such that it can be copied identically in each box as it will refer to the row it is in. is that possible?

    Many Thanks

    Denzil
    Attached Files Attached Files

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Denzil,

    Here is a macro that can be attached to each button. I have added this to your workbook (attached) in the same module as the first macro I wrote. You will need to edit the macro (code in red) to refer to the directory where the files are stored. After you have made the change then attach the macro to your buttons.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    02-05-2008
    Posts
    116

    Smile

    Hi Leith

    Im not sure if Ive done something wrong but ive changed the code to suit
    the location of the pdf files but a message comes up that says "There were no pdf files found to print in the following directory \10071" "
    PHP Code: 
    Sub PrintButtonMacro()

      
    Dim BtnName As String
      Dim FilePath 
    As String
      Dim MyDir 
    As String
      Dim R 
    As Long
      
        BtnName 
    Application.Caller
        ChDir 
    "P:\Design\PDF Standard Part Drawings"
        
          
    ActiveSheet.Buttons(BtnName).TopLeftCell.Row
          PrintFilesByType MyDir 
    "\" & Cells(R, "A"), "pdf"
      
    End Sub 
    Many Thanks

    Denzil

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Denzil,

    You changed the code, but not correctly. Here is the corrected version with your directory added in.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

  7. #7
    Forum Contributor
    Join Date
    02-05-2008
    Posts
    116

    Question

    Hi Leith

    Thanks again for your help

    Im not sure whats wrong but i put the corrected code in and the same message comes up, sorry to be a pain but have you any ideas please?

    Many Thanks

    Denzil

  8. #8
    Forum Contributor
    Join Date
    02-05-2008
    Posts
    116
    -----bump-----

  9. #9
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello Denzil,

    I am going out on a job in a few minutes and won't be back until early evening (EDT). If you post your workbook, zip it first before attavhing it, I will review the code for you and make any needed corrections.

    Sincerely,
    Leith Ross

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1