Get Current Folder Location In VBA

Apr 20, 2012

How to query the current folder location in VBA?

The macro will need to import text from a file (file.out) located in iteration folders (iteration_001, etc) but I need to start by seaching the location that the excel file has been saved in.

View 5 Replies


ADVERTISEMENT

VBA Create New Folder In Current Location And Save Selected Sheets As PDF

Feb 2, 2014

I have the below code that saves selected sheets of my workbook as pdfs in the current file location. What I would like this code to be able to do is to create a new folder (named with todays date), and then save each of the pdfs into this folder.

Code:
Sub SaveWorksheetsAsPDFs()
Dim sFile As String
Dim sPath As String
Dim fPath As String
Dim wks As Worksheet

[Code] ........

View 3 Replies View Related

Change The Folder Location

Dec 14, 2006

which part of this macro I need to edit to make it open a folder I want?


Sub OpenFolderRequest()
YesNo = MsgBox("Would you like to open the folder to see" _
& vbCr & "which files are currently there?", vbYesNo + vbQuestion, "Open Folder?")
Select Case YesNo
Case vbYes
myval = Shell("c:winntexplorer.exe c:winnt", 1)
Case vbNo
End Select
End Sub

I have tried changing the (c:winntexplorer.exe c:winnt) to the location name of the folder I want to open (S:Stock ControlSTOCK CONTROLOrder Confirmation)but it doesn’t seem to work.

View 9 Replies View Related

Generate A Folder Within A Specific Location

Nov 12, 2008

I am trying to generate a folder within a specific location (For now lets call it C:Jobs) that will be named as per the adjacent cell (Column H on attached)

Obviously if the folder already exists I want the code to stop.

But this code will have to generate a different folder for each row within the spreadsheet.

View 8 Replies View Related

Macro To Copy Folder From One Location To Another

Jul 12, 2012

I'm trying to write a set of macros and one of the macros needs to move a folder with subfolders from P:CJ to P:WO

Now I've been using the CopyFile State. Is there something similar because in my search they talk about using FileSystemObjects and I have now clue how to use those.

View 1 Replies View Related

Button Icon Folder Location

Oct 10, 2007

I am running WinNT and need to find the folder containing the default icons available for use on buttons in the toolbar window. I can copy the image but it saves as a picture (device independent bitmap). I want to be able to send the icon to other people so they can put it in their directory and choose to select it.

View 3 Replies View Related

Save File Under Current Name In A Selected Location

May 4, 2006

I get an xl file sent to me every day which I upload into a database. I then save the file keeping its name and save it into a selected folder. Is it possible to add a macro at the beginning of my current macro that saves the file using its name to a selected folder?

View 4 Replies View Related

Copying Data Irrespective Of Folder Location

Jun 4, 2012

I have a folder "Macro" in the below location in my PC:

C:UserskkumarDesktopMy WorksMacro

There are 4 excel files in this folder:
Sales.xls, Quantity.xls, Forecast.xls and Macro.xls.
Macro.xls has 3 sheets: Sales, Quantity & Forecast.

I want a macro which will pull all data in:
Sheet1 of Sales.xls to "Sales" sheet of Macro.xls
Sheet1 of Quantity.xls to "Quantity" sheet of Macro.xls
Sheet1 of Forecast.xls to "Forecast" sheet of Macro.xls

Also one additional requirement is if I copy the Macro folder to some other location in my PC the macro should still work.

View 3 Replies View Related

Change Default Folder Location For Hyperlinks

Feb 24, 2008

When someone right clicks on a cell and chooses "Hyperlink" current folder is being displayed as a default.

is there a way to change this for a particular workbook through VBA or API calls ?

I would like to always have "c:" as the default folder no matter where the workbook is stored.

View 9 Replies View Related

Create Folder Location Lookup From Database Values?

Feb 7, 2014

I have a template for information that needs uploaded into a database via CSV. This database is then access via a HTML front end. As part of this there is a 'folder structure' with in the front end. This is displayed in a database table (See attached excel file for example data structure)

Currently I have this feeding into a drop down list which is somewhat cumbersome so want to make it more efficient and easier to use. I had toyed with the idea of adding more columns into the excel template and split the string up to populate however this isnt exactly professional looking.

My current thinking is, is there a way of putting this data into a listbox which is easy to navigate? Ideally in a folder tree navigation structure, I know this is possible for a windows folder structure

Folder Structure.xlsx

View 1 Replies View Related

List Folder Location And Filenames Into A Table And Color?

Apr 14, 2014

i want to use the "Browse for Folder" to select the folder where the files is in eg. E:My DocsGlobal and list the folder location and filenames to table (column I:J), and color them according to every folder location.

I would like the "Browse for Folder" windows to be able to select multiple files instead of just one file a time.

View 1 Replies View Related

List Filename, Location & Attributes Of Files In Folder

May 21, 2008

Sorry that I'm very new in Excel VBA coder. And, for this topic, I don't even know how to start. I want to make a MS Excel database of a numerous files. This database must be consist of Filename, Location, and it's attribute (let's say updated date, size, hidden status)

View 2 Replies View Related

Open Multiple Files, Check Current Month & Save To New Location

Sep 15, 2007

I have 40 files in one folder which I named it as "CA" + month's name that I am working on. I need to do analyse these files monthly and save it under new folder. how do I automatically save them in new folder and name them for that particular month. Also, each file has worksheet which has one cell as "Aug-07" and the cell next to it has number of that month that is "08". How do I automatically change this also based on the name of the file, because file name month and month in the cell are the same.

View 9 Replies View Related

File Backup To Different Folder Location Automatically Whenever Workbook Closed

Feb 10, 2014

1. A workbook is closed

2. In addition to the original workbook being saved, a copy of the workbook with the current date is also saved to the specified location of my choice.

For example

"C:UsersUSER1DesktopBackup Test as of 02-10-14"

3. If a copy of the workbook is already saved with today's date, then overwrite it automatically without prompting the user.

4. All the above happens without any user interaction.

View 8 Replies View Related

Entering Current Folder Into A Cell

Oct 29, 2013

I have been looking for a way to enter the folder where the excel file is located into a cell.

I have seen you can add the whole path (=CELL("filename") ), however I am only wanting the 'last' folder it is in. For Example:

C:docsfolderdataClass D4John WayneProfile.xlsx

Would enter "John Wayne" into cell. The cell is namely the "name" cell.

I work in a school and a teacher is wanting a couple of different excel files for each student (600 students) I am hoping that I can put the files in a folder with the students name as the folder. That way at least its only 600 names and not 600x7! The other details are similar on a lot of the files such as class (this is also one of the folders in the path).

View 3 Replies View Related

Save File To Current Folder

Apr 23, 2009

I'm running a macro that intially opens an input box where you specify the filepath and name of a .ped file to import into the macro. The default path of H:BOM2.ped may not always be the path I use. It may be just H:.ped or H:Bom1.ped.

HTML INITIAL CHECK
Response = MsgBox(".............do you want to import BOM data?", vbYesNo)
Do Until Response = vbNo
'SELECT RAW FILE
Dim Message, Title, Default, MyValue
Message = "Please Enter PathFile Name for Source File"
Title = "Create CHINA INSPECTION REPORT(s)" ' Set Title.
Default = "H:BOM2.ped" ' Set Default.......

View 9 Replies View Related

Use Macro To Open Folder For Current User?

Jul 16, 2014

The macro works when I have my user name in the path but when I try to insert an environment it does not work.

View 3 Replies View Related

Excel VBA Current Folder Without Complete Path

May 15, 2009

What's a proper way - in Excel VBA - to get the current folder *without* the preceding folders/path?

For example from folder "C:oracleora81sqlplusdemo" I'd like to retrieve "demo".

Currently I have:

Code:
DirNames = Split(ThisWorkbook.Path, "")
CurrentFolder = = DirNames(UBound(DirNames))

It works, but I suspect something exists specifically for this one.

View 7 Replies View Related

Formula To Open Current Folder One Level Up

Jul 29, 2008

I have this formula that opens the current folder where my file is stored:

=HYPERLINK(MID(CELL("filename"),1,FIND("[",CELL("filename"))-1),"Open Current Folder")

This works fine. I'd like it to open the folder one level up from the current folder, but I really don't understand formulas well enough to know if this is even possible.

View 9 Replies View Related

Save Workbook With Current File Name To Specific Folder

Dec 4, 2007

I recorded a macro to save a workbook to a specific folder using the current file name. However, I've tried to remove the absolute reference to a specific filename but it is not working for me. Am I close?

ActiveWorkbook.SaveAs Filename:= _
"H:Files and DocumentsPROJECTSSR 2 SS Phase Two Component ReliabilityWinTrac Files xt_conversionsexcel_version" & SheetName _
, FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False

View 2 Replies View Related

Macro To Save Files In New Folder With Current Month And Date

May 6, 2014

I have this existing macro which saves each tab into a separate excel file. However, I'd like for it to also save them together in a new folder using the current month and date (named: QA Files May_05.06.14). The month and date would change according to current month/date. How would I incorporate that into this code? I am not good with macros.

Sub tabname()
Dim ws As Worksheet
For Each ws In Worksheets
ws.Activate
ws.Name = Range("D1").Value
Next

[Code]...

View 4 Replies View Related

Macro To Save As File To Current Daily Folder, Path Changes

Aug 6, 2008

I have a report send to me daily. And I want to have a macro to save this report in the daily folder, such as “c:

eports8052008”, so tomorrow 's folder would be “c:eports8062008”.

All the daily folders already exist. Just need to change the file path. I tried some codes including sPath and format(now(), “mmddyyyy”), get error message.

View 9 Replies View Related

Save File In Respective Month Folder As Per Current Year Vba Modification

Apr 3, 2014

In sub which will convert file to PDF and save it to assigned folder and then attach it to email in outlook. All works fine.

However is is possible to modify the code to save fole to respective month folder ( as per current date and year)?

e.g. I have created folder Named 'Trial' in C drive . This has sub folders 2014, 2015, 2016, 2017, 2018 Each year folder will have sub-sub folders month wise like This has sub folders as Jan , Feb , Mar , Apr .... till Dec Now e.g. if date when the pdf was created is 23/4/14 then it is saved in C:Trials2014Apr automatically. Currently every year I keep creating new folders etc... bit primitive though.

View 2 Replies View Related

Excel 2010 :: Using Current Month / Date And Time In A Folder Path In VBA Code

Feb 4, 2014

I’m working on a project using Microsoft Excel 2010 and I want to add some features to facilitate saving and retrieving files process.

1.How can I save the daily created workbooks (Assume 15 files a day) in order to contain the current date (and time if possible) linked with certain cell(s) I have at my workbook forming the file name? (XYZ 2-4-2014) and/or (ABC 2-4-2014 23:11) and so on …

2.I’ve been through some other posts and I found VB code which saves the active file into specific path, but it is only useful for single workbook because multiple files are getting overwritten automatically. Is there a code which allows multiple/different files saving & creates daily folders?

View 4 Replies View Related

Current Cell Location In A Cell

Aug 5, 2009

I need a function(s) that can indicate the current cell column and row in two different cells.

e.g.
Let's say in Cell A1 should indicate the column of current selected cell and B1 indicates the row of current selected cell.

A1 would read - 7 and B1 would read X if the current cell is at X7.

I do not know VBA. If you give VBA solution, please give me link on how to activate the codes.

View 10 Replies View Related

Interpolation Given A Variable Table Location & Location Of Data Within

Oct 6, 2009

I am trying to develop a spreadsheet that will calculate a cost based on a matrix. I am attaching a sample of the calculation created so far. The end result is in cell M13 and is highlighted in yellow. I kind of layed the formula out in a few different cells, so hopefully it would be easy to follow.

simplify this process with maybe another formula that I might not be aware of, or maybe show me how to get this done in VB code. I think VB code would be the correct way to go just not sure.

View 6 Replies View Related

Calculate Maximum / Minimum Value Of Current Value Based On Current Value And Previous Value In Data

Jan 6, 2013

I have series of data values like below. I have to find Maximum, Minimum values for each of these values.

9430
9822
10070

[Code].....

View 2 Replies View Related

Save To A Folder That Is Current Month And Have It Save To Next Month?

Jul 14, 2014

Here is a macro I am using to save a workbook using 'Save As' .

I have it open a template workbook we use, and then perform a save as, pathed to a specific folder on the desktop. We do this every night just before midnight.

What I haven't been able to figure out is how to have it save to the next month folder (The folders with the name of all the months are already created) on the last day of each current month.

For example. In my code, the final folder in the path is the current month July. On July 31 when I run the macro, I would like it to save it in the folder called August.

Is there a way to code this so it will recognize what the current month is and then at the end of each current month save it in the next month?

[Code] .....

View 12 Replies View Related

Lookup Folder From Cell Text Then Save Excel File In This Folder

May 14, 2014

I have alot of project folders on my harddrive.

All in format: I:/12345-costumer-projectname/

The five digits are unique for each project.

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.

View 4 Replies View Related

Excel 2003 :: Extract Variable Rows Of Cells From Files In A Folder To Existing File In Folder

Mar 15, 2013

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".

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved