VbA Code To Automatically Put Date Filename And Default Save Location
Aug 11, 2008
I have a spreadsheet that from a button I want to run a macro that will input todays date, the value in cell A1 as the filename into a default dialog box that is at a default file path. I have been trying to do this for several hours and can not completely get it done.
I have a workbook with 4 worksheets the first is called "input" which I use to enter information which goes to the other worksheets which arecalled engine, gearbox, doors.
I am stuck on the following; after inputting the information. I want to save as pdfs in various locations.
Is it possible to have 4 buttons on the input sheet which automatically :
Button 1 - Save "engine" worksheet as a pdf to a specified folder Button 2 - Save "gearbox" worksheet as a pdf to a specified folder Button 1 - Save "doors" worksheet as a pdf to a specified folder Button 1 - Save the sheets as multiple excel files to a specified folder
Below is a bit of a big macro i'm writing but I'm not sure how to edit my code to append the date after the filename. Then i'll need to refer to the exact filename later in the code?
I want to create a macro that when executed changes the name of "File1" to "File1 - Edited 8-9-2012". With the date being today's date (variable). This file is going to be emailed to someone who will then execute this macro.
Is there a way to prompt the Save As window with the updated file name so the user can save the file where ever he/she wants?
I am running a macro in Excel which automatically generates a PDF of my worksheet. Currently it saves in the default location but i want to modify it to a specific location - P:Emergency Services|Procative ContactForms PDF.
I have had my server removed that I had my default file location, when I go in to change any of my options the first thing it does is go look for this file location and brings back an error stating it cannot find the server. I cannot find anywhere else that I could change it.
I have the following code, is it possible to direct to a default directory that the file might be in? So when I open the dialog box it will automatically redirect a directory that is stored in VBA.
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)
What I am trying to do is that I have an excel file with macros and it is a read-only file. In order for the user to save, I want them to only be able to save as a .xlsx file as it disables all macros. If for whatever reason, the user wants to save the file as another .xlsm file, they should be allowed but before they save, a "are you sure you want to save as .xlsm?" message should pop up.
All the options in the save as box should still be available in case they want to save in that particular format. Just that the .xlsx should be the default.
When I use the GetOpenFilename() method, it seems to default to the particular users My Documents. Is there a way to force it to default elsewhere like a share drive, or the users desktop?
In the same line of thought, if I have a file named TestFile.xls. and I want to try to open it from the users desktop if they have it, how can I do this, since their desktop location is different than mine?
I want to write a piece of code that will automatically do a SaveAs on the workbook I'm using, say every hour, and add the current system date and time to the filename every time.
I'm using Excel 2010. When I go into the Excel Options, to the Save option and try to type in a specific network drive in the Default File Location: box, I click OK and then it doesn't save the changes. I close Excel down all the way and then restart a new Excel session and it keeps going back to "LibrariesDocuments..."
It doesn't seem to be just related to Excel...having the same issue in Word and Access 2010 as well.
Is there any way of making the default directory location for application.getopenfilename work properly with shared locations?
Presently I use ChDrive then Chdir but I cant use ChDrive if workbook is opened from a link in email for example. Please see below
I have a VBA routine that asks the user to load an existing file on startup.
I want the window for the file selection to open at the same folder every time. (the folder is on a shared drive)
The workbook to run the code will always be located on this same share at a fixed location.
My present code builds the path to the desired opening folder by collecting the drive letter from the current working directory (which has to be done as everybody maps there shares to different letters here, its not guaranteed to be the same! )
then i ChDrive to this letter.
Then I ChDir to letter plus myKnowndirPath
This works fine, the window always opens at my required folder. But only as long as the user has navigated to the folder containing the spreadsheet and then ran it from there. Because that way a drive letter is available.
However i found that if i sent a link to the workbook or its home folder. And the user opens the link or a windows explorer from that link and then runs file from there.
Then it stops working beacause there is no local drive letter in the working directory path. i.e. working directory shows as
I use an image analysis program ImagePro which can call Excel within it's macro language (which seems to be visual basic). I looked up on this site how the change the drive (ChDrive command). But still when the Excel section (after With oExcel) executes the default file location in the browser is in My Documents on the C: drive.
Prior to this code Excel has been launched by this ImagePro macro, and a file Cumberland Template has been opened from the C: drive. Now I would like to do a Save As, but have Excel start at the I: drive location.
I have an excel file that I use to track all my financial investments. The file is already set up with a query to retrieve stock prices when I refresh the document.
I would like to be able to open up the document, and store the closing price of the stock(s) with a date in the next column over. With this information I can graph weekly, monthly annually, or any time period I want.
I have been searching for a couple of hours now, and I could not find anything similar to this. I would think this is a pretty common idea for many people tracking their investments with Excel, so if it has been covered perhaps someone can point me in the right direction.
I don't have any programming experience in excel so as detailed of an explanation as possible
when i use this code i wnat the date to automatically appear in the text box but it doesn't I have type something into the textbox then the current date appears,.
I want to schedule a print, for lets say every Sunday at midnight. I have managed to find some what of a solution by using the following vbscript and scheduling a print to default printer. Works perfectly if that is all I wanted.
Dim objExcel, objWorkbook, strFile ' Connect to Excel Set objExcel = CreateObject("Excel.Application") strFile = "C: est.xls" ' Open the Excel File for Printing Set objWorkbook = objExcel.Workbooks.Open _ (strFile) ' Print to Default Printer Set objSheet = objExcel. ActiveWorkbook.Worksheets(1) objSheet.PrintOut objExcel.ActiveWorkbook.Close objExcel.Application.Quit
I do not want to print to an actual printer, therefore if I set my default printer as the document writer, the vbscript gets it as far as the "Save As" page. Is there a way I can add to this vbscript so it will save as well? Can I get it to save as "name"&[DATE], thereby having it save as a different name each time? Can I change this vbscript to print to a named printer rather then a default printer? I am sure a PDF convertor may be of some assistance with this, but I do not have an PDF converter on my computer, and as this will be carried out on a computer that I will not have administration rights, I can not download one.
I'm trying to make a vba that would save the file with the end date that will reference to a certain cell that user selects it. Working Sheet is a name of a File, and Current Sheet is a name of the panel where user will select the date.
I want a macro that will save a copy of the current file using specific naming convention. My file is called OTR2CMMASTER - I want the macro to save a copy as OTR2CMSAGE(CURRENTMONTH/YEAR). The OTR2 is a named field (ProjectCode) in the workbook.
I'm trying to use the code below to paste special my first sheet to remove the formulas, then delete all other worksheets then save as a reference number (which is linked to the worksheet im saving) but I also need it to save in a specific folder.
I have the following code allowing the user to save a file using a custom macro button. However, I do not want to let them change the name of the file, just the location. How do I do this? ...
I'm trying to record a macro that calls up the saveas dialogue and uses a filename from a cell (it's the w/c date). I can start recording the macro, open the dialogue box and copy the contents of the cell but i can't get it to paste as the filname.
What I'm trying to achieve is to allow users of a muli-sheet workbook to be able to click on a 'save' button on any sheet and have the workbook save with a filename which includes the current week commencing date. This way all the weeks changes will be in just one file and from the following monday a new file will be started the the old one left alone as an archive.