Solved

Changing part of a macros function (Selecting a pdf file from numerous pdf files in a directory)

Posted on 2013-12-01
2
184 Views
Last Modified: 2013-12-01
Below is macro code currently in use:
Sub DuplicateRename()
    strFileCopyFrom = ThisWorkbook.Path & "\" & "Template Checklist.pdf"
    For Each c In Range(Range("A2"), Range("A" & Cells.Rows.Count).End(xlUp))
        strFileCopyTo = ThisWorkbook.Path & "\" & "Template Checklist" & "_" & Format(c, "000") & ".pdf"
        FileCopy strFileCopyFrom, strFileCopyTo
    Next
End Sub

The "Template Checklist.pdf" is fine in there is only one document with that name in the folder.

The folder will soon contain numerous PDF files. Is there an easy way to select the needed file and still fulfill the rest of the macro's function?

Thanks for any suggestions.
0
Comment
Question by:dgd1212
2 Comments
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points
ID: 39688968
This will ask for a number and will do it to the file with that number
Sub DuplicateRenamebynum()
    strFileCopyFrom = ThisWorkbook.Path & "\" & "Template Checklist.pdf"
    c = InputBox("File Number")
        strFileCopyTo = ThisWorkbook.Path & "\" & "Template Checklist" & "_" & Format(c, "000") & ".pdf"
        FileCopy strFileCopyFrom, strFileCopyTo
End Sub

Open in new window

0
 

Author Closing Comment

by:dgd1212
ID: 39689004
Thank you!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INDEX and MATCH can be used to great effect to replace HLOOKUP and VLOOKUP as it does not have the limitation of needing the data to be sorted so that the reference value is in the first column or row. It also has the ability to perform a bi-directi…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question