Saving Workbook In Newly Created Directory

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


ADVERTISEMENT

Newly Created File Not Saving At The Given Location

Jul 1, 2014

I have an issue with saving the file at the desired location below is the code i have currently used . I have given the destination as "D:New folder". The new file does get saved at location "D:" but not inside the "D:New folder", instead names the file as "New folder".

View 3 Replies View Related

Copy Paste Cells To Newly Created Workbook

Aug 9, 2008

My code in the first workbook generates a new workbook with a variable in the filename, then copies the cells from the first workbook to the newly created workbook. This code is working properly when used in a draft worksheet I use for testing. As soon as I put it in the master file, an error message pops up "Runtime error 1004 : select method of range class failed". Then the debug sends me to the line " Cells.Select ". What should I be looking for, why does my code work on one file but when i put it in another one it doesn't ?

Private Sub CommandButton1_Click()
Dim line_counter As Long
Dim prm_line_value As Boolean
prm_line_value = False
Do
prm_line_value = Sheets("Rate").Cells(1 + line_counter, 1).Value
line_counter = line_counter + 1
Loop Until prm_line_value = False
line_counter = line_counter - 1
Dim Wk As Workbook
Dim number_of_new_wb_needed As Integer
If line_counter < 5000 Then.....................

View 3 Replies View Related

Paste Into Newly Created Tab

Jul 21, 2009

I originally posted this in the "Excel New Users forum" - i guess that was an error, but I'm very new (second post) and very new to VBA in general - so please be gentle!!

I've created a macro which opens a workbook, creates and renames a new worksheet, and moves it to the end of the workbook.

I then need to paste into this new worksheet a selection from another workbook.

How would I specify in the code that the selection needs to be pasted into the newly created tab?

View 12 Replies View Related

Paste Special Into Newly Created Tab

Jul 21, 2009

I've created a macro which opens a workbook, creates and renames a new worksheet, and moves it to the end of the workbook.

I then need to paste into this new worksheet a selection from another workbook.

How would I specify in the code that the selection needs to be pasted into the newly created tab?

The code I have so far is as follows:

Worksheets.Add.Name = Workbooks("SHEET1").Worksheets("monthly report").[p1]

ActiveSheet.Move _
After:=ActiveWorkbook.Sheets(ActiveWorkbook.Sheets.Count)

Windows("SHEET1.xls").Activate
Range("A1:N23").Select
Selection.Copy

However, I got a subscript out of range error pointing at the line of
Worksheets.Add.Name = .Worksheets("monthly report").[p1]

View 9 Replies View Related

VBA / Creating And Attaching New Sub To Newly Created ActiveX Control?

Jun 2, 2014

After programmatically creating a new activex checkbox, I want to create a sub for it's click event. I have given the object a name, and fortunately the code for it's click event is a one-line call of another sub, but how?

The sub would look like the following except be named after the new control (obviously), and yes, it is just the number in the name that changes:

[Code] .........

View 2 Replies View Related

Newly Created Tab Names Placed As Hyperlink On Content Sheet

May 11, 2006

I attach an example worksheet with the code I have thus far.

In my workbook I have other sheets, one of which changes and updates a specific one each time a new client's data is entered on said other sheet. Because I want to save the specific client's data and not lose it when another client's stuff is entered on this other sheet, I copy the sheet where the data is summarised (I called this sheet "Sheet to Copy From") to a newly inserted sheet and use Paste Special, Values Only to change all functions /f ormulae / Links ect to values.

I then change the name of the sheet to the name of the client.

I then use this sheet name / cell value to polulate a range on another sheet (Next Empty Cell) as a Hyperlink to the newly created sheet above. This sheet I called "Table of Contents".

how to code the hyperlink. Using Macro Recorder uses the specific case's names, but the Tab name to be used as Hyperlink value will always be the name of a new client,

View 8 Replies View Related

Clicking Cancel On InputBox To Delete Newly Created Sheet

Mar 4, 2010

I created with code to copy a template, hide that template, and pop up a box to rename the copy, I noticed she clicked "Cancel" on the InputBox. When she did, she received an error (400). What I would like to do is when the "Cancel" button is clicked, the newly created copy would be deleted. Is this possible?

Here is the code for my full "Create New Project" sheet procedure:

Sub CreateNewProject()
'This code will copy the Project Data sheet, hide it and then
'rename the new copy to the MSA number. Code also prompts user for
'MSA Number and fills that in on the form.
Dim RenameSheet As String
Dim oSheet As Worksheet
With Sheets("Project Data")
.Visible = -1
.Copy After:=Sheets("FHWA Quarterly Report")
End With...............

View 9 Replies View Related

Excel 2010 :: Creating Multiple Tables In VBA And Referring To Newly Created Tables?

Jul 1, 2013

Using Excel 2010. I'm writing a macro that sets up a workbook to be used for estimating at the beginning of a project. In the code I need to create multiple tables (formerly known as "lists") in the workbook. Then later in the code I need to refer back to those newly created tables. Currently, the code that creates the table is part of a loop that creates the table on many different worksheets. The problem of course, is that I have to name the Table, and then it won't create a table of the same name on the next sheet. Then, later in the code, I need to make adjustments to the table that was just created before looping to the next sheet.

Is there a way to create a table without giving it a constant name? Or by giving it a name that builds off of other info in the sheet? For example, I would be good with the naming the table after the sheet name: "Sheet1_Table" or such.

Code:
Sub Auto_Open()
'
Dim sht As Worksheet
If Range("A1") = 1 Then

[Code].....

View 2 Replies View Related

Saving Only With Self-created Button Possible

Jul 17, 2012

I'm working on a Tool, where every change should be saved in a new Version. So if the user changes any number, he should click my selfcreated save-button, which takes todays date in the filename (no problem so far).

I tried to disable the "normal" save-button with:

Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cancel = True
MsgBox ("saving cancelled!")
End Sub

Unfortunately this code won't allow my own button to save too. Is there any other way? Maybe sth like if "normal" saving is used, then automatically activate a makro (which is also on my button) instead of just saving?

View 2 Replies View Related

Saving MSForms.control Created At Runtime

Aug 16, 2006

I have code that creates a row of controls on an MSForms.Userform at runtime.

I would like the user to be able to save these controls so that they are available the next time he opens the form. The user would be able to add or delete a row of controls and save them AND the values that he has set. This allows great flexibility for each session using the form.

The values aren't a real problem - I've been using the SaveSettings function for the design time controls values. The runtime controls are combobox, textbox, listbox, checkbox.

I don't want to design-time build the controls and just toggle the visible property (not a good solution for my app).

View 3 Replies View Related

Saveas Dialog: Closes The Created Spreadsheet Without Saving It

Oct 20, 2006

I have a workbook that has twenty data sheets. The user presses a button that copies they're specified sheets to a new workbook and prompts them with the SaveAs Dialog. How do I code it so that if they press the CANCEL button on the SaveAs Dialog it closes the created spreadsheet without saving it?

View 6 Replies View Related

Escaping Default Directory When Saving And Printing

Oct 16, 2009

This code works fine, as long as Excel isn't pointed to the default directory. But, when it is in the default directory ("My Documents" for me), then it will only save to the default directory. I need to save to a network drive. Is there a way to do this without me going to the "open" a new file button to switch out of the default directory?

View 2 Replies View Related

Renaming Sheets (newly Opened Workbook And Change It's Name)

Feb 12, 2008

I'm experimenting a bit with this code. The idea is the following:

I've got one spreadsheet (ThisWorkbook) were I define 5 names for 5 worksheets in all files of a specific folder (c: emp). I get stuck at this line: "wb.Sheet2.Name = myval2", since I'm for some reason not able to activate the newly opened workbook and change it's name....

Sub wd_testing()

Dim I As Long
Dim wb As Workbook
Dim firstrow As Long
Dim sht As Worksheet
Dim cell As Object
Dim count As Integer
Dim myval2 As Variant
Dim myval3 As Variant
Dim myval4 As Variant
Dim myval5 As Variant
Dim myval6 As Variant
Application.ScreenUpdating = False

It's important to mention that there is no name conflict and the names work when entered manually.

View 9 Replies View Related

Closing A Workbook Created?

Mar 25, 2014

I've created a macro which copies the current tab to a new workbook (Book X):

[Code]....

I then manipulate the copied data in Book X. Once this is done I move the manipulated sheet back into original file

[Code] .......

The problem i'm having is I'd like to close the newly created Workbook X file once the macro has run but Workbook X is usually called Book2, Book4, Book7, Book32 etc.

Workbook X will always be the previous file if i use the ALT TAB shortcut.

View 2 Replies View Related

Add-in Opens Workbook It Was Created In

Oct 27, 2006

I've created an add-in that runs a simple macro. The problem I have is that when I run the add-in it opens the workbook I originally created it from - is this what I should expect it to do? How do I stop this from happening?

Also, do I need to have the workbook from which I created the add in located in the same place on every machine I want to use the add in on? At the moment if I move the original workbook the add-in won't work.

View 9 Replies View Related

Creating New Workbook / Copying Sheets And Saving Workbook - Subscript Error

May 30, 2014

Trying to create a new workbook from another open workbook, then copying all the sheets that aren't called "Summary" to that new open workbook and then saving it. I get a subscript error on this line:

[Code]....

View 3 Replies View Related

Refer To Workbook With Name That Is Created By Macro?

Sep 28, 2011

I have the following code that creates a new workbook and names it after the value of a cell in another workbook. Another part of the macro will switch back and forth between the original workbook and the newly created workbook.

What is the best way to refer to new workbook? I'm familiar with the "workbooks "VARIABLE NAME".Activate" style but, the name of the new workbook will change every time the macro runs and I'm not sure how to refer to it.

the code below.

HTML Code:
Sub MakeNewBook()
Dim wB As Workbook
Dim nPath As String

[Code]....

View 3 Replies View Related

How To Identify Workbook Created From Template

Nov 7, 2013

I have created a spreadsheet that I wish to save as a template. However, when the a new workbook is created from the template it needs to be saved as a Macro Enabled workbook not just a workbook which is the default. To achieve this I added the line 'thisworkbook.FileFormat=xlOpenXMLWorkbookMacroEnabled' to the 'beforesave' macro for the workbook. This works fine except that it makes saving the file as a template quite difficult.

How I can trap the first time a workbook created from a template using New is saved would be most useful.

View 6 Replies View Related

Workbook Does Not Copy To Vba Created Folder

Sep 22, 2006

I am having trouble getting a copy of current workbook to save (with a hopefully unique name) into a vba created folder. The folder creates fine on any drive that I have access to, but the workbook never turns up. The code is only an extract from the whole but it still fails in isolation.

Sub Macro1()
Copyit:
Dim fso
Dim fol As String
Dim flag As String
fol = "E:Excelb4macrobackups" ' change to match the folder path
Ans5 = MsgBox("Create Backup of " & ActiveWorkbook.Name & "?" & vbCrLf & vbCrLf & " Backup File Path:" & vbCrLf & vbCrLf & fol, vbYesNoCancel + vbExclamation)
If Ans5 = vbNo Then Exit Sub
If Ans5 = vbCancel Then MsgBox "Procedure Terminated!", vbExclamation: Exit Sub.........

View 2 Replies View Related

Extracting Information From A Workbook And Saving Into A Separate Workbook

Feb 21, 2014

i have a workbook blank template for my colleagues to fill in, they fill in this blank template and save it under the serial number of the item they are creating. However a lot of errors exist when they input the serial number inside the workbook where the serial number is a duplicate of a former serial number.

Anyhow i was wondering is there any way when they input the serial number into the worksheet that i could get it to save in a separate workbook and then have conditional formatting to check those serial numbers in the workbook to see if they match?

View 4 Replies View Related

Extra Files Created In Same Workbook Folder

Jan 22, 2009

I have a Workbook that is located in a Networked Folder and is used by several people every day. The Workbook has a lot of VBA and also has links to other workbooks. I am noticing that over time there are several extra files being created from this excel workbook, in the same folder. The Workbook is the only file in this folder. They are not associated with any program and are just a File Type. They are titled a series of 8 random Letters and Numbers and range is size from 700 KB to about 1 MB (Slightly smaller then the Workbook file size).

Also, Is possible to automatically delete these files when they are not needed? or better yet is there some way to Prevent these files from being created in the first place?

View 3 Replies View Related

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 View Related

Save Workbook As Copy To Another Directory

May 20, 2009

I need save my workbook as copy to another directory, ( C: ) with VBA code

View 9 Replies View Related

File / Workbook Created By Macro Is Making It Heavier?

Jul 4, 2014

I am creating 4 Sheets from a Main Sheet by Filtering Data based on different values in a fixed column, then the Filtered Rows are automatically pasted in the respective sheets.
Then these 4 Sheets are creating another file.

The same thing done manually by Grouping the 4 SHeets and then Move Copy into a New workbook also makes the file heavier.

Everything works fine however though the data is not much the file is very heavy, so what do i do to make it of appropriate size ?

View 1 Replies View Related

Linking Dynamically To Other Workbook In Directory Specified In Cell?

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

How To Create Copy Of Excel Workbook In Same Directory

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

Kill Command - Using Directory From Workbook Cell

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

Search For Workbook In Specific Directory, Based On Keyword

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

File Copy Macro - With Directory Specified In Workbook Cell

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







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