Saving A Workbook Via The This Workbook Module

Mar 20, 2007

I will shortly be running a project over a twenty four hour period, where a group of people will be inputting data into a workbook (one worksheet per hour), and what I would like to know is if it is possible, to input some coding into a thisWorkbook module to action a save on the workbook every time an entry is placed in column A (of each worksheet) which is divisable by 10 (a10, a20, a30 etc).

View 2 Replies


ADVERTISEMENT

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

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

Copy Module To Another Workbook

Jul 14, 2006

Is there anyway to copy a module from one workbook to another using a macro?

View 6 Replies View Related

How To Copy Module(s) To Workbook In Different Path

Jun 21, 2013

Want to Copy a Module(s) to another workbook in a different path and also password protect it at the same time using VBA.

I need to copy some Module(s) from One WorkBook to another using VBA..

I have used the following code to good effect, however my TargetWb is not at the same path, so I need some modification in this code if that's possible and also this VBA Module which is Copied and Pasted in the Target WOrkbook needs to be Password Protected so that it cannot be tampered.

The code which I'm using currently is:

Code:

Sub CopyModule(SourceWB As Workbook, strModuleName As String, _
TargetWB As Workbook)
' copies a module from one workbook to another
' example:
' CopyModule Workbooks("Book1.xls"), "Module1", _

[Code]...

Code:

Sub Try()
Call CopyModule(Activeworkbook, "Module1", TargetWb)

on this to pass the TargetWb as a variable which can be generated in the code used for generating the File using a Macro..

End Sub

In the above code The SourceWB would be the ActiveWorkbook and the Target Workbook is the file created using another Macro from several sheets of the Active Workbook and its created in a folder with a specific name and therefore the Path is one more level inside than the Active Workbook.

if the Transferred Module can be Passworrd Protected and Locked for editing..for the end user.

View 9 Replies View Related

Add Password-Protect Module In Another Workbook?

Jan 18, 2014

I am creating a File/Workbook using MACRO, however i need to ensure that one of the Modules in the created workbook remains protected and hidden...

Since there are lot of these files which are created, I would be interested in protecting them via a macro..

View 4 Replies View Related

Copy Module To External Workbook

Mar 26, 2009

I have been trying for some days to copy a module to an external workbook with VBA. I have about 40 workbooks that have the same format. although I developed these sheets. I am not the person who uses them. I have to on occasion alter the code for some reason, its getting tiresome.

I don't think I can use the personal workbook method for this as it is not me using the workbooks. I don't even know some of the people that use them. This courses me problems because of the number of workbooks. I want to be able to maintain the code by having to write it once and propagate it through the necessary files via the VBA.

I have code from C Pearson that copies a module to another workbook.

I have posted this here just in case. Most threads on this subject just direct you here any way....

View 9 Replies View Related

Auto Copy A Module To A New Workbook

Aug 26, 2009

If possible, Can a module be copied into a new workbook from the master workbook. When the one I have does not copy the modules when creating a new workbook. If so it would make my life a bit easier.

View 9 Replies View Related

Update Code In The Workbook Module

Mar 15, 2007

I have multi- sheet workbook that opens to a specific ws and to a specific cell.

Application.Goto Reference:=Worksheets("Menu").Range("A1"), _

One of the several ws is a form; when the user saves it, all other ws are deleted and the wb is saved as a new file name. (Need to retain other macros for future functionality, seems easiest to just delete the unneeded sheets).

Is their a way to modify the sheet reference from "menu" to "sheet-name" (will be a constant). Because it is likely that additional sheets will be added in the future to this new wb, I'd like for it to open to a specific ws.

As my VBA skills are "in development" (basement level, just now), please provide a complete answer (assuming this can be done).

View 9 Replies View Related

Error With Running VBA Code Module For Another Workbook

Mar 13, 2012

I have a workbook which I regularly upload that cannot have macros within it; however, to update and process the data, I must utilize VBA Code.

I tried to work around this by storing my macros in a module in another workbook. My process is to have the VBA Code Module from the other workbook open and have the active workbook be the one I want to change, then I run the VBA Code from the other workbook.

This used to work. However, I am recently getting problems with the Code not running correctly. Sometimes it only runs the code if the affected cells are not hidden; other times it will not run the code at all!

View 4 Replies View Related

Closing Workbook After Calling External Module

May 6, 2007

I have a workbook (Program_1.xls) which references another workbook (Program_2.xls). I want to close Program_1.xls using code in Program_2.xls.
When the Program_1.xls is closed, the code stops.

Program_1.xls code

Sub Program_1()
MsgBox "This is program #1"
Application.Run "Program2.xls!Program_2"
End Sub




Program_2.xls code

Sub Program_2()
Source = "C:Documents and SettingsCohenMy Documentsprogram3.xls"
target = "C:Documents and SettingsCohenMy Documentsprogram1.xls"
Workbooks("Program1.xls").Close savechanges:=False
' ---> code halts here
MsgBox "This is program #2"
FileCopy Source, target
End Sub




How do I get the final 2 lines of code to execute?

View 9 Replies View Related

Access Private Module Of The Workbook. 2007

May 15, 2008

I want to write some code that runs everytime the workbook is initialized. I found out that the code should be placed in the following "Private Sub":

Private Sub Workbook_Open()
'My code
End Sub

I know that this code should be placed in the Private Module of the Workbook! I just can not find where is the Private Module of the Workbook in Excel 2007... =/

View 3 Replies View Related

How To Delete Another Excel Private Module Of Workbook Object

Jul 9, 2013

How to delete another excel private module of the Workbook Object (ThisWorkbook) VBA codes of the workshook event.

This code to run from my PERSONAL.XLSB
Sub Macro1()
Windows("Book1.xls").Activate
ActiveWorkbook.Vbproject

Don't know what other codes I need to put after this
End Sub

This code to be deleted via Macro1 above code
Private Sub Workbook_Open()
Call CreateMenu
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Call DeleteMenu
End Sub

View 2 Replies View Related

Exporting Macros To Another Workbook From The 'sheet' Code Module

May 30, 2007

I've used the following code to export macros from one workbook to another but I was wondering how you export macros from the ' Sheet' code module to the 'Sheet' code module of another workbook.

Sub Import_Macro()

With ThisWorkbook.VBProject.VBComponents("ThisWorkbook").CodeModule

strRet = .Lines(1, .CountOfLines)

End With

Set wkb = Workbooks("Test Workbook.xls")
wkb.VBProject.VBComponents. Import ("G:SCSSCSALLReportsVB MacrosGeneral.bas")
wkb.VBProject.VBComponents.Import ("G:SCSSCSALLReportsVB MacrosMJ Selections.bas")

With wkb.VBProject.VBComponents("ThisWorkbook").CodeModule

.DeleteLines 1, .CountOfLines '//Delete Codes already wrriten
.InsertLines 1, strRet '// Write Code

End With

End Sub

View 8 Replies View Related

Excel 2010 :: Accessing VBA Module From UserForm On Workbook Open

Feb 13, 2013

I am using Excel 2010 and late binding to generate reports. The sheets are blank and unused. I have the UserForm being opened on Workbook_Open and the actual VBA for doing the work in a separate macro in the workbook. All the posts I have found are dealing with accessing cells from the UserForm and I haven't found any dealing with connecting a macro to the UserForm output.

My question is this: I want to return from the UserForm the flags of which reports to run to the (unopened) macro containing the code to do so. How do I open the macro and pass the variables to it?

The UserForm is creatively called "SelectionForm" and the macro is called "DailyFTP" with a Main sub as the entry. I know I can use the code under to capture the radio button and checkbox choices. I have other variables like the names of files set as global variables in the DailyFTP macro. The macro doesn't exist until SelectionForm opens it, so they must be set after the macro is in memory.

View 6 Replies View Related

Saving Just One Tab Out Of A Workbook

Dec 4, 2008

I have an Excel doc with ~20 tabs. Each type represents 1 type of activities (soccer, tennis, etc). The size of the file (with the 20 tabs) is pretty significant (>1mb), which jams our email traffic.

Is it possible to:
- keep this workbook with the 20 tabs when open by the user;
- let the user select and fill in whatever tab he needs (just one at a time);
- have a button for the user to click that will save only this tab with a different filename (therefore, when sent by email, the file should be pretty small).

View 9 Replies View Related

Macro Addin That Inserts / Runs And Removes Module In Active Workbook

Mar 24, 2013

I have a macro that copies data from several workbooks saved in a particular folder to a master workbook.

The problem is that this macro only works when it is included as a module in the master workbook. Unfortunately, I cannot ask the users of this macro to insert a module, copy the code and run it each time they want to consolidate the master workbook. Therefore, I wanted to use this code by including it in a Add-In that I already prepared. The problem is that this consolidation macro does not run when it is in an add-in. Create a code that I can include in a macro add in that would insert a module in the master file, include the code that I already have, run it and then delete the module? The add-in would be password protected.

View 7 Replies View Related

Closing Workbook With VBA Without SAVING?

Nov 27, 2012

I'm trying to close a workbook without saving it. But everytime I get the message box popupped twice.

These are the codes that I use:

VB:
Private Sub Workbook_BeforeClose _(Cancel As Boolean)
Dim YesOrNoAnswerToMessageBox As String
Dim QuestionToMessageBox As String

[Code].....

View 4 Replies View Related

Crashes When Saving Workbook...

Jun 8, 2009

As I've learned to develop Excel apps with vba over the years I've noticed that, if the Excel app starts to get too large (over 1MB) saving it will often cause the application to crash for no apparent reason - the result being that I lose all the vba code I entered before the last save - with the worst case being that, on occasion I have lost all of the vba code in an applications!!!

So, I've learned to back up often using a third-party utility that I use to save my applications, which works wonders in allowing me to save my application without it crashing. The application is called Code Cleaner 97.exe. It was designed around Excel 97 (which I still use) but if possible I'd like to get an updated version for Excel 2003 and Excel 2007, which I also use.

Does anyone know of a more recent version of this utility, or another similar utility that allows large Excel applications to be properly saved, etc?

Code Cleaner 97.exe was a freebie that was available through one of the old Compuserve Excel forums. It was a very popular utility and was suggested as a means to save one's Excel apps without the app getting trashed, etc.

I'm not expecting a freebie solution so I'll gladly pay for something that allows me to save my large Excel apps without them crashing, etc.

View 2 Replies View Related

Rename Workbook Without Saving In VBA?

Apr 5, 2010

Is it possible to rename a new workbook without saving it. What I do is I create a new workbook but I don't want to save it:

Sheets("Layout").Copy

Now Sheets("Layout") is standing in a NEW workbook called Map1.xls.

I want to rename Map1.xls to Invoice.xls without saving the workbook.

Then I do:

Application.Dialogs(xlDialogSendMail).Show
ActiveWorkbook.Close SaveChanges:=False

View 9 Replies View Related

VBA - Creating And Saving New Workbook

Oct 26, 2011

Ok, I'm trying to learn how to create and save a new workbook using VBA...having some issues with this error:

Run-time error '1004':

Method 'SaveAs' of object '_Workbook' failed.

The line is highlighted in red.

Code:
Sub Copy_ActiveSheet_1()
Dim FileExtStr As String
Dim FileFormatNum As Long
Dim Sourcewb As Workbook
Dim Destwb As Workbook
Dim TempFilePath As String

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

View 7 Replies View Related

Macro For Saving Workbook

Dec 24, 2007

I Want A Code That Will Save My Workbook To A Specific File (different Form The One It Is Currently In) Using The Name That I Have Typed In Cell D13 In The Workbook

View 9 Replies View Related

Saving Workbook In VBA And Location

Dec 20, 2008

I am using this code in my ThisWorkbook, but it keeps coming back as an error for

ActiveWorkbook.SaveAs Filename:=ThisFile

Private Sub Workbook_BeforeClose(Cancel As Boolean)
'Saves file as what is in cell "C7" to specified network location - variant below
Dim Location, ThisFile As String
Location = "\Office-pcpublicCustomers"
ThisFile = Range("C7") & Format(Now(), "dd/mm/yy")
ThisFile = Location + ThisFile
ActiveWorkbook.SaveAs Filename:=ThisFile
End Sub

View 9 Replies View Related

Saving As A Workbook Through Inputbox

Feb 6, 2009

When the button is pressed, It opens a Mesage Box giving an alert to the User about what is He going to do...if he clik no the macro stops, if the user click yes then it opens an InputBox ....and the name the user writes there will be the name of the new book...

If working good if the user press OK ...my problem comes If the User press CANCEL in the InputBox...The excel try to Save the file as FALSE...and I don´t know how to avoid it.

Here is the code.

Sub Botón1_AlHacerClic()

X = MsgBox("Warning Bla bla ".Are you sure ?", vbYesNo, Title:="IMPORTANTE")

Naa = Application.InputBox("Write the file name Here", "New File Name")

If X = vbYes Then

ChDir "C:UsersROBERTODocumentsBASES DE DATOS"
ActiveWorkbook.SaveAs Filename:=Naa, FileFormat:=xlNormal _
, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False

End If
End Sub

View 9 Replies View Related

Workbook Doesnt Allow Re-saving

Dec 14, 2009

i have a workbook which is mainly use in construction building design... i want users to input ther respective data in that workbook to calculate and design only, but i dont want the user to save the changes they made...

View 9 Replies View Related

Shared Workbook Saving

Mar 5, 2010

How do I get a shared workbook to automatically save upon every change by each user. The only way I can get this to work (at this point) is to run a macro that updates every 45 seconds IN EACH WORKBOOK! It's counterintuitive because the workbook is shared (on a network), but each user must start the "time" macro in their "individual" SHARED workbook to allow the automatic saving.

What am I missing? There has to be a more efficient way to do this, right?

Code below
HTML Sub Time()

Call Save
Application.OnTime Now + TimeValue("00:00:45"), "Time"

End Sub

HTML Sub Save()

ActiveWorkbook.Save
End Sub

View 9 Replies View Related

Prevent Saving A Workbook

Jul 5, 2006

I'm wondering if it is possible to prevent a user saving a workbook. If opened as a read-only, excel throws up an option to save with an alternative name. I'm wondering if I can put some code in the Workbook_BeforeSave event that prevents saving of the document unless the application.username is myself.

View 2 Replies View Related

Saving Sheet But Not The Entire Workbook?

Mar 14, 2013

All I want to do is save a copy of one sheet called "Patient Stock Form", change the name to "Patient Order", and put it into an email. But my code is putting the entire workbook into the email. Here's the code:

VB:
Sub EMAILFORM()
Dim oApp As Object ' Outlook.Application
Dim oEmail As Object ' MailItem

[Code]....

View 8 Replies View Related

Saving Userform Data To Different Workbook?

Oct 29, 2009

Is it possible to have a userform open in a workbook and when the data from the form is saved, save it to a completely different workbook. If so, will that other workbook need to be open for the userform data to be saved?

View 5 Replies View Related

Closing The Workbook & Saving Automatically

Jan 25, 2008

I have my Excel workbook open & have made changes. Now I close it and Excel prompts me if I want to save the changes. Is there a way to just close the workbook and automatically accept any changes without have the "Do you want to save changes" message appear?

What about if it is opened in read-only mode? Typically the workbook will not save any changes unless you save it off as another file name. If there is a solution to my question above, can it be enabled only when the workbook is opened in edit mode, or will it not auto-save changes over the file because Excel knows it was opened in read-only mode?

View 9 Replies View Related







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