Defining Workbook Save Directory
Nov 5, 2008
I have managed to get my workbook to save with a filename based on two textboxes. I am not sure, however, how to define the directory. I have tried adding a ("mydirectory") on the saveas line but it does not work.
This is my
Private Sub CommandButton2_Click()
Dim wb As Workbook
Set wb = ActiveWorkbook
Dim strText As String
strText = txtLMSRef.Text & "," & txtPartial.Text
wb.SaveAs Filename:=strText
wb.Close
Set wb = Nothing
End
End Sub
View 9 Replies
ADVERTISEMENT
May 20, 2009
I need save my workbook as copy to another directory, ( C: ) with VBA code
View 9 Replies
View Related
Sep 8, 2006
Read “My Documents” Path And Use Result
Problem:
Note:
Typical user OS will be Windows XP Pro / Win 2K
Excel version : 97 / 2002 / 2003
1. Corporate network security settings will only allow directory/subdirectory creation in the “My Documents” section of customers individual computers.
2. Per customer request, VBA application needs to save extracted files for future use.
3. I can specify an initial “My Documents” subdirectory be made and the VBA application file be loaded/copied into that location – i.e. – “My DocumentsCat”.
4. When VBA application is opened from that specified directory, (first time), the application needs to make an additional subdirectory tree to save future files. I can read the opened from location via VBA with the following:
Dim filepath As String
filepath = ThisWorkbook.Path
As an example – this code would produce a string definition of “filepath” – such as the following:............................
View 5 Replies
View Related
Dec 3, 2006
what code can be used to be place in a Command Button on a worksheet that will use the value in a cell, change it to the directory where it have to be saved and save it to the value of another cell. Example:
On a worksheet called "Customer", at cel A1 will be the customer's name and at cell A2 will be the asset number. Now let's say a directory does not yet exist on the root for this customer, a new directory must be created in the root directory by using the name in A1, and the workbook must then be copied and saved under the value of A2.
View 6 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
Feb 2, 2010
The Kill function works OK but the ThisWorkbook.SaveAs part does not work for some reason.
Please note that there are 2-spaces between the words: P3 CATS
View 12 Replies
View Related
May 11, 2006
1. Is it possible to save additional worksheets (right now it is only copying one worksheet)?
2. How can I hard-code the directory path so the file goes to that one locatin (i.e. the "master directory")?
Also, is it possible to save userforms out of this workbook (i.e. some of the userforms contain information that is useful...it would be great to have them in the "output" file that gets saved to the "master directory"). Thanks!
Private Sub SAPfile_Click()
myfile = Application.GetSaveAsFilename(fileFilter:="Excel Files (*.xls), *.xls")
Worksheets("Output-SAP Plan").Copy
ActiveWorkbook.SaveAs myfile
ActiveWorkbook.Close
MsgBox "SAP file created."
End Sub
View 9 Replies
View Related
May 15, 2013
I am trying to use VB to save a workbook into the same directory but with a file name that references the folder it is stored in...if that makes sense!
Here is where I have got to so far but fails on save,
Sub Rename()
Application.DisplayAlerts = False
mdy = Month(Now()) & "." & Day(Now()) & "." & Year(Now())
fold = ThisWorkbook.Path
FName = fold & "-" & mdy & "-(New).xls"
SaveName = fold & "" & FName
ActiveWorkbook.SaveAs (SaveName)
Application.DisplayAlerts = True
End Sub
View 3 Replies
View Related
Mar 16, 2007
I have a workbook that will save as if certain conditions are met. The workbook saveas filename is determined by user input into a textbox. I would like to define the path but allow the filename to be the value of the textbox. I used the ChDir function to do this but it is not working. Here's what I have:
Private Sub CrmFrm1_Click()
ChDir "S:AccountingProbationTest Files"
If Len(TextBox1) <> 12 Then
MsgBox "Incorrect Case File Number"
FrmSave.TextBox1.SetFocus
Exit Sub
Else
ActiveWorkbook.SaveAs Filename:=FrmSave.TextBox1.Value
End If
Unload Me
End Sub
View 2 Replies
View Related
May 20, 2013
I have a button that saves my excel workbook to a network drive, but what I'd like to do is have it save the file to a directory named after the user, instead of all the users in the department saving to one folder. For instance, R:customerserviceweight reconstructionusername, where username a directory named after the user.
Code:
Private Sub Save_Click()Dim Path As String
Dim FileName1 As String
Dim FileName2 As String
FileName1 = Range("A2")
FileName2 = Range("A3")
ActiveWorkbook.SaveAs Filename:="R:CustomerServiceWeight Reconstruction" & FileName1 & " - " & FileName2 & " - " & Format(Date, "yyyymmdd") & ".xlsm", FileFormat:=52
End Sub
View 1 Replies
View Related
Oct 2, 2007
I am looking to see if a directory exists, and if it does, to save a file in it, otherwise create it, then save the file. My IsFileThere function works fine on files, but does not detect directories. The len(Dir(Filename)) statement always returns a 0, with the Dir statement always simply populating with "". It works fine on filenames - so can anyone tell me why it does not pick up directories?
Shouldn't the Dir function on a directory name return "."? I have excerpted some of my code to include here: Global Const StoredJobsSubdirectory = "Jobs"
Dim AppPath As String: AppPath = ActiveWorkbook.Path
'other code in here - activeworkbook changed, hence previous line
If IsFileThere(AppPath & "" & StoredJobsSubdirectory) Then
ActiveWorkbook.SaveAs FileName:=AppPath & "" & StoredJobsSubdirectory & _
"" & NameString & ".xls"
Else
MkDir AppPath & "" & StoredJobsSubdirectory
ActiveWorkbook.SaveAs FileName:=AppPath & "" & StoredJobsSubdirectory & _
"" & NameString & ".xls"
End If............................
View 2 Replies
View Related
May 7, 2014
In my VBA macro, it copies data from this.workbook, and paste to another "destination" workbook. That destination workbook must be opened first before the macro is run.
Within the Macro code, I had to specify the exact name of the workbook which the data is pasted to.
The problem is that the exact name of that workbook which it paste to changes every week.
Is there any method where my macro can be changed and updated with the name of the destination workbook each week without manually opening and editing the code. The user of this.workbook is not technical enough to edit and maintain the macro each week
View 8 Replies
View Related
Jan 21, 2012
how, via VBA, to save a worksheet ("ForExport") from my workbook into a new file (type CSV). To provide additional difficulty (not by my choice), the users will all have their own directories on the network to save their files into. These directories will NOT be mapped drives (e.g., "C:") but rather will be UNC paths (\parentusername)
So, obviously the filename and location are both rather dynamic, depending who is using the excel template.
The workbook has three sheets:Base Form (sheet 1)ValidationResources (sheet 2, provides data for menus/validation)ForExport (sheet 3, contains data written to it from the Base Form)
The workbook has fields to capture UserName, FileName (without an extension), and FilePath.UserName = captured by VBA code from the users login informationFileName = concatenated field based on some other fieldsFilePath = concatenated field of a set parent path (\parent) plus the UserName (so, \parentusername)What I want to do is have a macro that takes the ForExport sheet, saves it as a CSV file (with the file name from the field holding that info) into the directory I've specified in the FilePath field.
Is what I'm trying to do even possible? I have a sample workbook I can provide if you need something to work with. Not sure if I can attach it here.
View 2 Replies
View Related
Oct 29, 2012
I have some code that copies a worksheet and saves into a new workbook and saves into a specified folder and renames the new workbook.
It is all working fine however it is saving to my desktop and not the specified directory. I know there is a lot similar out there and i have exhausted my google skills trying to find the similar format to the one i am after.
Code:
Sub MonthlyReset()
Dim sourceSheet As String
Dim clearR As Range
Dim newFile As String
[Code]....
View 2 Replies
View Related
Jun 17, 2014
I have recorded the below code that functions fine from my computer. My issue is that I need to export/import this macro to other workstations who may have the save to location mapped to a different drive letter. Is there a way to replace the drive letter with the URL (SharePoint)?
ChDir "E:3. CRQsRemedy Dumps"
ActiveWorkbook.SaveAs Filename:="E:3. CRQsRemedy DumpsToday_CRQ_8Dump.xls" _
, FileFormat:=xlExcel8, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Save To Directory: \server_1Dir_1Dir_2FolderToday_CRQ_8Dump.xls
Permissions are in place.
View 1 Replies
View Related
Apr 1, 2014
I am using this code to generate a text to a directory, but I would like to know how to call a save as prompt if the directory doesn't exist?
[Code] ..........
If the folder macro does not exist, then it will prompt a message saying that the folder macro cannot be found, and the save as prompt will appear.
View 3 Replies
View Related
Mar 3, 2014
I have several hundred text files which I would like to reformat and save as excel without needing to open each file individually.
I'm entirely new to working with macros, so, I was able to use macro recorder to save the steps to reformat the file, but would like setting up the part of the macro to automatically open and reformat all of the files.
View 2 Replies
View Related
Dec 3, 2012
I have an expense report, which was originally done in Excel 2003. It still prompts users to open as read only however if they select no, they are not prompted for the password, and it has allowed them to save, so when the next person opens it, they have the previous person's report instead of the clean workbook. I have tried everything to put a password onto it. I know this is really basic stuff, but maybe I am missing a step? I want the end user to be able to make all the changes they want in read only mode and then do a save as, but if the select No when prompted "Open as Read-only?" they should have to put a password in.
View 4 Replies
View Related
Mar 6, 2014
Using Dropbox, a lot of people will fill in formulas in personal workbooks from using data from another, central workbook. Since I cannot control where they install Dropbox or where they keep their personal workbooks, I must account for that in functions.
Now, my idea is to make them define the directory of the source in their personal workbook in a specific cell and then using that as a basis for the rest of the functions.
Example
Cell A1: C:Usersuser1Dropboxfolder (copy paste from path in Windows Explorer)
Cell B1: A1&[CentralWorkbook.xlsx]SheetName'!$H$1
Basically I want the unknowing user to copy-paste the path of the central workbook into a specific cell in their own workbook and then build my functions bsed on that. How can this be done?
View 2 Replies
View Related
Mar 20, 2014
I have Workbook named"Test_Template" in below specified path this is not the active workbook.
It is saved in strFName = ThisWorkbook.Path & "Backup" & "Test_Template.xlsx"
I need to create a copy of the same workbook named as "Copy_Test_Template.xlsx" in the same folder(Backup), same specified path on button click.
[Code] .....
But this creates a "Copy_Test_Template.xlsx outside the Backup folder, i want it in the back up folder.
View 2 Replies
View Related
Jun 18, 2009
I am trying to have the user hit a button and save the workbook in a newly created directory. Currently it creates the new workbook and the new directory with the correct names, however the workbook is not in the newly created directory.
View 5 Replies
View Related
Feb 15, 2010
I want to use the following kill command to delete all files in a folder:
Kill "C:dsmanagerest*.*"
However, I want the directory to be specified not within the code, but within a cell on a worksheet. Ie. Cell A1 would contain the directory C:dsmanager est*.*"
View 6 Replies
View Related
Nov 10, 2009
I am trying to find code that locates a workbook (file) in a specific directory, based on a keyword and stores the workbook location in a string to be opened later.
For example, find a workbook containing the word "ancaster" in it's file name (actual file name is "ancaster_summary_2009") in file path:
"C:My Documents" and store the filename and path in a string called "ancasterBook"
View 4 Replies
View Related
Feb 23, 2010
I am continuing to struggle with my first attempt at a macro, and wonder if someone would mind taking a look to see where I have gone wrong? All I am trying to do is create file copying tool where the user can define the source and destination directory in workbook cells, and assign the macro to a button to complete the copy of all files from source to destination.
The macros do this:
Source and Location directory defined in Sub Archive1.
These are passed to file copy macro Sub ArchiveScript.
This macro checks for presence of destination directory, ensures that the directory backslash is in place, specfies the variables fn and fn2 to make sure the filecopy command copies all files in the directory, and then carries out the filecopy function itself.
However, I am getting two errors from the code that I can't figure out (I am still very much a beginner!)
- Invalid procedure call or element on fn = dir() at the bottom
- The copy still works, but only seems to copy one file from the source to the destination, and not all of them.
View 6 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
May 3, 2006
Firstly, I have attached a file called test2 which has two sheets within it, one called list and one called 12345. This is for demonstration purposes only as in real life these are both separate files.
What I am trying to do is create a history in the file called list that extracts certain data from the file called 12345 and places it in a more user friendly format. No problems with the formulas etc, just a case of a few ifs and buts.
My real problem lies in the fact that file 12345 is only one of hundreds of files and in order to create the history, I have to repeat the process on all the other files, so that the list grows as I copy the data.
Again for demo purposes, the file "list" sits in the C root ie C:list and the job files sit in C:files*.*.
Is there a way to automate the process so that formulas or VBA residing in the file "list" searches through the C:files*.* and populates the list as it runs through them.
View 9 Replies
View Related
Jul 16, 2014
I am trying to quickly transfer all worksheets in a directory into one worksheet listing all worksheet names in the tabs in number order.
The formula have so far is below. But it does not name the individual tabs as the worksheet names in no order.
Sub GetSheets ()
Path = "Y:
Filename = Dir(Path & "*.xls")
Do While filename ""
Workbooks.Open Filename:=Path & Filename, ReadOnly:=True
Sheet.Copy After:=ThisWorkbook.Sheets (1)
Next Sheet
Workbooks (Filename) . Close
Filename = Dir ()
Loop
End Sub
The worksheets appear as follows 1982-001, 1982-003 up to 1982-250 ( I want them in single workbook but as multiple tabs in number order)
View 1 Replies
View Related
Jul 31, 2009
I have figured out how to save the workbook using a variable to saveas but I would like to create a new folder to place the new workbook into. I have tried a few things a am not having any luck. I recorded a macro and the code it produced is as follows.
View 6 Replies
View Related
Apr 5, 2007
I have a update/Save button on a spreadsheet. So when clicked it updates another sheet and saves the workbook.
how can i have it run the macro when they don't click the button and do
File -> Save.
View 9 Replies
View Related
Jun 17, 2014
I have been trying to edit a code which previously saved a copy in a new workbook to a specific folder/path. (Additionally it copies and clears some figures, but this is working as it should.)
However I would like the copy to be saved at the same location as the original workbook, regardless of the path the original workbook is saved.
I.e if I need to move the workbook containing the code to a new folder/location, when using the macro, the new copy should be stored in the same folder/location as the original one.
For now it is only saving the copy into "My Documents"
Code:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 16-02-2009 by ceng
'
Sheets("Bunker ROB").Select
Sheets("Bunker ROB").Copy
ActiveWorkbook.SaveAs Filename:= _
ActiveWorkbook.Path & Range("D3"), _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
[Code] ........
View 2 Replies
View Related