Open File From Directory & Name Stored In 2 Cells
Aug 29, 2007
I have numerous sub directories, C:/Jobs/12500 – 12599, C:/Jobs/12600 – 12699 etc, within these directories exist spreadsheets with file names like 12675.xls (in this case it’s in the “12600 – 12699” directory). In my open spreadsheet, in cell A1, there is a job number, say 12675. I want to find and open the existing 12675.xls spreadsheet. If the spreadsheet does not exist, a template (Costing.xlt), in a fixed directory, is opened and then saved, in the correct sub directory i.e. C:/Jobs/12600 – 12699/12675.xls. I am now using the following code, but the directory is fixed. How can it be modified to work with variable directories?
On Error Resume Next
Workbooks.Open Filename:="C:Spreadsheets" & Range("A1") & ".xls"
If Err <> 0 Then
Workbooks.Open Filename:="C:SpreadsheetsCosting.xlt"
ActiveWorkbook.SaveAs "C:Spreadsheets" & Range("A1") & ".xls"
End If
On Error Goto 0
View 3 Replies
ADVERTISEMENT
May 31, 2013
I have a tool file which contains Excel VBA codes. When I click button it asks to select a file. I want that anytime I click the button the dialogue box should open in the folder containg the tool.,
View 1 Replies
View Related
Jul 26, 2007
Can i open a workbook without knowing the directory? more importantly without showing the directory?
I want open the file "EstimatingSheet" where ever it is.
View 9 Replies
View Related
Mar 11, 2014
I have a Workbook "forecast.xlsx" and several Workbooks which have a individual Number in the Filename (E.g. "3960........xls", "3961.......xls etc.) in the same directory as "forecast.xlsx" + projects"
Now, I would like to browse through "forecast.xlsx" in column H, searching for hyperlinks. In Column H are these Projectnumbers located which are used in the filenames above. Whenever the Cell cointains a hyperlink, following should happen (that far i managed it by myself):
- Store the Cellvalue in a String Variable
- Go to the Directory this.workbook + projects
- browse this folder, searching for a File which contains the stored string in its filename
- open the file
- copy a range
- close file
- This.workbook.Activate
- follow the Hyperlink which has been stored as String before
- paste selection
- continue browsing through column H, looking for the next hyperlink.
I have a VBA which runs bugless, but it copies the wrong range, but to the correct destination.
See the code below:
Sub RESLT_INPUT_ALL()
Dim cell As Object
For Counter = 1 To 1000
Set cell = Worksheets("Projects overview").Cells(Counter, 8)
If cell.Hyperlinks.Count > 0 Then
[Code] ......
View 1 Replies
View Related
Jun 10, 2009
I am trying to prompt the user for the directory to be saved in and file name to be saved as; then save the workbook in the input directory with the inputted file name.
View 3 Replies
View Related
Nov 17, 2006
I created folder on my desktop to hold various documents. I have master excel document which contains forms and command buttons that open documents from same folder. Is there a way to change code instead of having full file path to specify current directory. I'm worried that if I move this folder to another location then my open file button will not work since location is changed.
Also when I open with command button word document, I have a button on word document to close. I can close document but word application is still active. Can I close word application with the document at the sam time. This is the code I'm using: "ActiveWindow.Close"
View 3 Replies
View Related
Apr 25, 2012
I'he a button in Excel Userform and i want to open directory using button cliick and put selected directory in textbox1 e.g. i've selected D:Susheel then it will reflect in textbox1
View 3 Replies
View Related
Apr 2, 2012
I have created a simple macro that inserts a header onto a sheet on the first row of a workbook. It works fine when the macro is stored in the file that I am wanting to paste the header into, but when I moved the macro to my "personal" folder it gives me a debug error with this code:
Code:
ThisWorkbook.Sheets("Bid Sheet").Rows("1:1").Insert Shift:=xlDown
ThisWorkbook.Sheets("Bid Sheet").Columns("K:K").ColumnWidth = 50
I am assuming this error is being caused by the phrase "ThisWorkbook" but I do not know how else to reference the workbook I want to run the macro on.
Full Code:
Sub Insert_Header()Dim wb As Workbook'Open Workbook
Set wb = Workbooks.Open("C:NewPage_Logo.xlsm", UpdateLinks:=False)Â Â Â Â
'Go out to File and copy logo and header Â
[Code] ........
View 3 Replies
View Related
May 5, 2006
I have done a search in the forum, and there are many results on browsing directory and opening files, but they are not what I have in mind.
What I have is different folders for different months (e.g. “January”, “February’, “March” and so on), and in each folder I have the same file names (e.g., in “January” folder, I have files called A, B, C. In “February”, I also have files A, B, C but these are different from the files in other folders)
Basically I need a macro which can open a specific list of files.
So first step, the user should be able to browse the directory, then select a folder (no need to open, not sure if it makes any difference though). I need the user to be able to select different folders because the macro should work for the different months in different years.
For this, I have found this
Function GetFolderPath() As String
Dim oShell As Object
Set oShell = CreateObject("Shell.Application"). _
BrowseForFolder(0, "Please select folder", 0, "c:\")
If Not oShell Is Nothing Then
GetFolderPath = oShell.Items.Item.Path
Else
GetFolderPath = vbNullString
End If
Set oShell = Nothing
End Function...........
View 9 Replies
View Related
Mar 11, 2007
Is it possible w/ some vba code to copy the names of files, either from a search or a specific directory to an Excel Worksheet?
View 9 Replies
View Related
Oct 16, 2013
I am having trouble creating a hyperlink to a place in the current document for a file stored on a network drive. My workbook has a lot of sheets (50 or so), so I created a 'Navigation' sheet that contains hyperlinks to all the worksheets located therein, and pasted a link back to the Navigation sheet in cell A1 on every tab.
Setting up these Navigation sheets has never a problem until I started posting the file on a network drive. As soon as I did that, I noticed that the internal hyperlinks on all sheets in the workbook would stop working after I closed the file in Excel. Note that this network drive is not set as a drive letter on my computer, and is only accessible by entering the server ip address in Windows Explorer.
An example address the hyper is trying (and failing) to open is: "file:///\ IP ADDRESS sub-folders activefile.xlsm"
I've tried a few options, using the HYPERLINK formula, using the HYPERLINK feature in the Insert ribbon, etc, but all to no avail.
View 8 Replies
View Related
Jan 10, 2012
I would like a macro that saves the current open workbook to a directory specified in a cell on the open work sheet.
View 4 Replies
View Related
Jun 29, 2014
How to open files based criteria in cells value?
[Code] .....
View 5 Replies
View Related
Oct 9, 2013
I've been playing about with this for ages, I have row 'U' which I manually link to local JPG files. Basically it has the word "HERE" and linked to a JPG that opens when you click it.
I'm really looking to just RIGHT CLICK a cell in column U, it opens a file browser, when I select the file it places HERE in the cell and links it to the file I've selected.
View 5 Replies
View Related
Apr 30, 2008
Is it possible, in vba, to copy two sets of cell values to two clipboards (clipboard1 and clipboard2?), open another workbook and paste those two seperate clipboard values into another two cells?
View 3 Replies
View Related
May 8, 2008
I need to copy multiple cells from 1 worksheet to another worksheet on different workbook and for every entry it has to create a sequence #
- source file (ex. data1.xls, data2.xls, etc)
* data & field structure is fixed
- destination file (case1.xls)
* field structure is fixed
1) destination file (case1) will be opened first, a button is prepared (associated w/ macro) and it will open the source file (ex data1.xls) & then copy the cells B2,B3 and E2,E3
2) the copied cells will be pasted to destination file (case1) in cells B3,C3 and D3,E3 respectively
3) a sequence # will be created in cell A of the destination file
this process will be repeated to other remaining files (ex. data2.xls same structure as data1.xls) manually. It means i will perform the task only if required. i have a created a simple code attached to case1.xls
View 6 Replies
View Related
Feb 8, 2014
I have my code here:
VB:
Sub openfiles()Dim Path As String
Dim ExcelFile As String
' Path = GetFolder("C:UsersKinteshDesktop")
Path = "C:UsersKinteshDesktopVBA programmingMaps"
ExcelFile = Dir(Path & "*.xls")
[Code] ....
NextCode:
GetFolder = sitem
Set fldr = Nothing
End Function
My problem is that the code all actually works (including the function and when I use the commented part), but pointing to this one specific directory (the one I'm using right now), literally nothing happens.
View 6 Replies
View Related
Feb 4, 2009
By Code I am trying to SaveAs the present Workbook : Only in the same directory as the present Workbook- but with a different file name. The new file name would be :"the Filename of the Active Workbook" + " ("D9") of the Sheet("ADMIN")". This macro will only be run from the Sheet("Admin").
View 4 Replies
View Related
Mar 5, 2013
How can i loop through each excel file in a directory.
View 1 Replies
View Related
Jul 1, 2013
I have a spreadsheet, where the corresponding invoice number is located in column I.
All the necessary invoices have been scanned in as pdf's in folder Y:FinanceSalesInvoices.
The question is, can a code be written to say in column Z, that a hyperlink be created to that particular invoice. For example, in cell I2, it would have Invoice1, then in cell Z2, it would have a hyperlink of Y:FinanceSalesInvoicesInvoice1.pdf.
View 1 Replies
View Related
Jul 18, 2008
I have a workbook that is produced by some other application that names the file "FAMMToday_#.xls"
Where # increases from 1 to 2 to 3 to 4 to 5 and so forth until all the analyst are done with adjustments. so the directory can look like but doesnt always go to five and nor is it limited to five.
"FAMMToday_1.xls"
"FAMMToday_2.xls"
"FAMMToday_3.xls"
"FAMMToday_4.xls"
"FAMMToday_5.xls"
Is there a way to pull the latest file?
View 9 Replies
View Related
Dec 7, 2008
If I know the name of the file how can I get that file’s directory (Address) with macro or function?
View 9 Replies
View Related
Jul 23, 2013
Basically what I want to do is to create a button which when pressed opens a file picker (I think its called this way) and the user should find and select a pdf file. And when he does that he clicks "OK" and this file is copied to specified folder.
View 7 Replies
View Related
Mar 1, 2014
The script below writes a ".csv" file to the same directory that contains the workbook the macro, "foo" is run from. I'd like to change the script to always write the file to a separate directory which is: "c:etcupload".
[Code] .....
View 1 Replies
View Related
Jul 21, 2008
I have an excel spreadsheet that has a list of pathways to different folders (ex. Q:TechnicalY001) in each row. I want a macro that will search each of the folders I list in a range of cells and return the most recent file by the Date in the filename:
Example: Cell A1 contains folder path Q:TechnicalY001
Cell A2 contains folder path Q:TechnicalY002
The macro would return the most recent file in Y001 and dump the filename into cell B1. Then it would return the most recent file in Y002 and dump the filename into B2.
After I have all of the most recent filenames, I want to be able to search each of those files for data in certain cells and then dump that data into the spreadsheet. The cells are always going to be the same in each file.
View 14 Replies
View Related
Sep 11, 2009
I've got this code that will copy data into my worksheet from the most recent .IRP file generated on my C:/ drive. Along with copying the data to my worksheet, I'd like to have a copy of the IRP file copied to a folder on my L:/Drive.
In the code section I've commented out the code that allows the data from the most recent file to be copied to my worksheet. I found code that supposedly will copy a file to a new directory. I want to combine this into my code to allow both to happen. Here's my attempt.
View 5 Replies
View Related
Mar 9, 2013
The code bellow allows me to save a copy of the invoice by way of doPDF using invoice number as the name of the pdf to be saved.
Code:
Else
Application.ActivePrinter = "doPDF v7 on DOP7:" 'Selects doPDF to genarate PDF file of invoice.
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= "E:LusaGenerated InvoicesINV" & Range("L17").Text & ".pdf", _
[Code]...
As there is the need to, should a quotation or an invoice be wrong, to change it. In other words I have code to cancel the invoice as bellow.
Code:
Dim sResponse As String
Dim rFound As Range
sResponse = InputBox("Enter record you want to change." & vbNewLine _& "ATTENTION!
This will change the current record number and will erase record data from saved records sheet.")
If sResponse = "" Then --cancelled or OK with no entry: do nothing or add message
Else
Set rFound = Sheet1.Columns("L").Find(What:=sResponse, LookIn:=xlValues,
[Code]...
The code above simply removes a line on sheet1 to which yet another macro retrieved some info from an invoice such as date, invoice, customer and total.
Now I just realized that when I change an invoice, I will be again when finished, creating another pdf file that already exists.
How can I have the second macro here changed so that it will go to ""E:LusaGenerated InvoicesINV" & Range("L17").Text & ".pdf", _" and delete this pdf file?
View 9 Replies
View Related
Nov 11, 2013
I have a 2 columns.
A: Current location Ex(C:UsersDesktoplabelsA02FAA.jpg)
B: Future location Ex(C:UsersDesktopoxes98300SA02FAA.jpg)
I want to move jpgs from location A to B
is there a way to execute this with a macro?
View 5 Replies
View Related
May 31, 2006
The file that this code is located in is often sent to others to use which means I have to modify the directory and path each time I send this file in order for the VB code to work.
Workbooks.OpenText Filename:= _
"C:My documents-2Monthend Supplemental ReportsDeficiency ReportscurrentC37.txt"
Is there a way to have the file opened from any active directory it happens to reside in?
View 9 Replies
View Related
Jun 4, 2006
In the following code, What do I need to add to allow the selected file to open when I click on it? I have a drop down menu that lists my .xls files.....as of now when I choose a file nothing opens.
Sub Auto_Close()
On Error Resume Next
Application. CommandBars("Patient List").Delete
On Error Goto 0
End Sub
'================================
Sub Auto_Open()
Dim cb As CommandBar
Dim ctrl As CommandBarControl
On Error Resume Next
Application.CommandBars("Patient List").Delete
On Error Goto 0
View 3 Replies
View Related