Excel 2003 :: Browse For Text File When Folder Root Is Known But Filename Unknown
Apr 25, 2012
I have run into a problem in a project where I know what the folder root of the file I would like to import into excel is, but I do not know the file name.
I would like to open a dialogue open where I can select the file I wish to import from the known root supplied and retain the file name as a string.
All solution I have read assume the full file root is know or file name is known but root is unknown
Now iam Working in excel 2003, I got a Requirement that, After Downloading datas From SAP, It Directly Stored in Excel Sheet , Using tht Sheet1, I need to rename all the Filenames at a time, Is It possible, Any code is there to rename,
For Example,
From SAP to Excel Sheet Datas are Like this in Sheet1,
I need a macro in a workbook to look at all the files in the same folder that have "*att*.xls" in the name and determine and copy from the range A15:W515 only the rows that have data in at least columns A, C and D. Each file will vary as to how many rows there will be and there are more than the files with "*att*.xls" in the folder. The data will be on the only worksheet in each file and the worksheet is named "G2WAttendee_xls" the data from all the files need to be copied to the file called "Consolidated webinar reports.xls" (I am using Excel 2003) and to a sheet called "Attendance Data" and added to the end of the last paste.
At the start of the macro the current file "Consolidated webinar report.xls" should be saved to a sub folder of the current directory and have the date saved added to the name. The sub folder is called "Completed reports". The data in the original file on worksheet "Attendance Data" should be deleted.
At the end of the process all the files that have had data copied from them should be moved to the sub folder "Attendance reports consolidated" (This could be done as each file is closed if that is easier).
I have headings in row 1 of the "Attendance Data" worksheet that match the headings in the various files in the folder (which will always be in row 14 of the individual "*att*.xls" files).
The folder with all the files and the "Consolidated webinar report.xls" file is at path "Z:P and S MEvaluationsWebinar series 2012-13TB".
I make calculations for these projects using an excel file. In this excel I also type the projectnumber (cell J2)
Now i would like to make a button. When pressed, it checks the projectnumber cell J2, looksup the corresponding folder and saves the excelfile in PDF format in this folder.
I have found macro to find files in folders, but none which do the above.
I am creating a document for work that automatically generates hyperlinks to pdf files in a given sub folder. Currently I have a section of code that opens a window to choose the folder location.
Code: 'Prompt user to select a directory Do Problem = False Set ShellApp = CreateObject("Shell.Application"). _ Browseforfolder(0, "Please choose a folder", 0, "c:\")
On Error Resume Next
[Code] ........
What I actually want is to not have the window open, but excel automatically choose the sub folder location.
The directory looks like this Z:ClientProjectDRAWINGS-2 RECORD COPIESPDF
The xlsm file is stored in the DRAWINGS folder, and I need it to point to the PDF folder.
I have some daily text files in a folder (so about 30 of them each month), which in the end of month, I need to open them up in excel, format them so that I can use the information for my analysis.
I would like to create a macro, to quickly open them all up at once and save them each individually in .xls or .xlsm format.
I am new to VBA and after some research online, I was able to have the files open with the following code. but now I don't know how to proceed further to save them one by one with the same name but in .xls or .xlsm format.
Sub Opentxtfiles() Dim MyFolder As String Dim myfile As String
I have created a browse button in excel and assigned a macro which will ask the user for folder. I figured it out for windows using Windows API Functions as mentioned at http://www.cpearson.com/excel/BrowseFolder.htm. However cannot get it to work for a Mac.
Is there a way to incorporate a prompt that allows the user to browse a folder. The code I am using is below but 'myDir' will change each month.
Sub CombineWorkbooks() Dim myDir As String, fn As String Dim WSName As String Dim WB As Excel.Workbook WSName = "Summary" On Error Goto Nxt 'turn off screen refresh for speed Application.DisplayAlerts = False Application. ScreenUpdating = False myDir = "C:Users\DocumentsUsersWendyNew Folder" fn = Dir(myDir & "*.xls")
I found some code that works well to index a folder and all sub-folders for file names.
The issue is that the folder used is coded in an excel spreadsheet (cell C7) in the below code and whether to look in sub-folders (cell C8 - True or False).
Code: Sub ListFiles() iRow = 11 Call ListMyFiles(Range("C7"), Range("C8"))
[Code]....
I have tried to incorporate the browse for folder and select if sub-folders are used, but it isn't working.
is it possible to type a document name in a cell,then run a code that searches a root dir and sub folders, find the existing document and open it?? for example
I'm on excel 2010 and I have a small group excel files I open everyday. Most of the files are static in name and location. I've got a macro created to open those files, which works fine with workbooks.open and the file path.
There are two report files I want to incorporate into my macro of workbooks to open. The files are created weekly and the files names have the following format: "Report Name (YYYY-MM-DD).xlsm". I don't want to use the file's last modified date because older files may get edited after the more recent ones are created. The files are also not always created on the same day, so the solution needs to be flexible enough to not refer to a specific day of the week or anything.
Macro open an excel file based on the latest date found in filename.
send automaticaly, or it waits until user will push button send or brows to attach the file.
In all given samples it says: “If you use Microsoft Outlook”. I know that any office has Outlook. Is it impossible to make Outlook usable with macro and then send an e-mail?
I have looked in books and online and can't seem to locate how to create a macro that opens a browse function. From Excel I would like to click a button to start a macro and have that macro prompt me where to browse for the file. There is a lot of other code that will go after this step (which I already have), so once I click to "open" a file I want the macro to continue.
Does VBA support any type of "browse for file" interface? I'm thinking something similar to an inputbox, but instead it gives you the standard looking windows explorer window to find a file (think adding an attachment in outlook). The function would return a string.
I have created a separate SAVE button that when the user hits that button, it saves the file in a network drive using the current date as part of the save-file name. Ie: Sheet20070408.xls, Sheet20070409.xls, Sheet20070410.xls, and Sheet20070411.xls.
I am currently working out all the "idiot proof" safety features. My code looks something like this:
Why am I saving it twice? When the user clicks SAVE, I want to save over the copy of the current sheet they use, even if they save it on their desktop, and then save it to the network drive. This way, if they keep a second copy in an easy to find location, it will save the data to that sheet as well. Just in case they forget to save on the current sheet. I need to be sure each copy of the file has the most up-to-date information, as well as save a copy for retention.
My question is this: Can I search a folder for an existing file name? If the user goes into the network drive to open an old file for retention and they click SAVE, I don't want to accidentally overwrite a file in the retention folder.
I'm looking to loop through a particular folder and depending on a reference contained within the file names move then to the corresponding folders and so on until the folder is empty.
I'm thinking the following can extract the reference from the filenames...
myRef = Mid(objFile.Name, Find("Ref -", objFile.Name) + 1, 5) but I'm not sure how to hold that information (5 number reference) and then match it to a corresponding sub directory of the folder.
I am trying to code where when someone hits the command button it will popup with the browse form and they find the location of the file and it puts there choice in a cell. don't know if it matters but the location would always be a picture. Here is what I have but it shows -1 in the cell
HTML Dim strFilePath As Variant strFilePath = Application.FileDialog(msoFileDialogFolderPicker).Show shUserInformation.Range("D12").Value = strFilePath
I have an Excel workbook with 2 worksheets in it. One of the worksheets imports a txt file and then the other worksheet displays data that formulas I have written have collected.
I usually import the txt file by running through the many steps with the "import data" option. This is good but I want it to be faster.
I used the macro recorder and ended up with the following code
Just striving to have this kind of "picture arrangement's macro" to work, macro that whenever you choose a certain cell and operate it on hotkey it'll:
1. Create a new folder named "PicturesAuto" beside the excel file (wherever the excel file located).
2. Inside folder "picturesAuto it'll create a new subfolder named by the same name of the sheet related to that cell you operated the macro upon. (let's say this cell placed on sheet named: "happysheet"- that'll be the name of the subfolder created.)
3. Inside the subfolder "happysheet" it'll create a new subfolder named by the text of the cell you activated the macro upon (let's say you initially operated the macro on B5 cell -which has the text "montana" so it'll create "montana" subfolder also inside subfolder "happysheet")
4. Lastly instead of having only the text "montana" in "B5 cell" like we had initially before activating the macro, the macro'll also add to that text "montana" the link to "montana" folder (path of excel file->picturesAuto->happysheet->montana)
The way I'm planning to use this is to add a lot of HR pictures inside those folders created by the macro that related to that specific sheet, and that specific cell I've activated the macro upon. Plus just having those pictures so organized is just outstanding in every scale, and the excel file will keep running smoothly without any resource consuming overload.
Every day I create many Excel reports that I manually save as PDFs for distribution to my stakeholders. I'd like to automate this process using a macro. I've seen the following code online and have attempted to use it, but receive an error in the Dim MyPDF line of code indicating that the user-defined type is not defined.
I'm using Excel 2003 and Acrobat Distiller 8. I have no problem creating PDFs manually
Code: Sub Create_PDF() Dim tempPDFFileName As String Dim tempPSFileName As String Dim tempPDFRawFileName As String
I would like excel to create the folder C:/Bill if it doesn't already exist when I click save/save as option and save the workbook in it with a filename that is a combination of text/values in cells A1 and A2 on Sheet1. Better if the save as dialog box appears with this option selected so that I have to just click Save in the save as dialog box to save it in "C:/Bill".