How Can I Activate An Open Workbook By Macro In Seperate Instances

Feb 24, 2009

I have a program that has all Excel Workbooks in seperate instances of Excel. There is a very sound reason for doing this.

The user has maybe 3 to 10 workbooks open. There are times when a workbook is active and has a Macro Link to open one of the already open workbooks.

When the user clicks the link, they naturally get an error message stating that the workbook is already open. Then they have to close the error msg and click on the Macrosoft Tab and look thru the list of open workbooks and then click the one they are looking for. Additionally, in this Menu Program the user really doesn't even have to know the name of the various workbooks.

I hope everyone will believe me when I state that this program works berautifully.

Right now I am simply cleaning up and making a few little things work better.

QUESTION When the user clicks on a macro link that is to open a workbook that is already open, how - On error - can I have the macro continue on and activate the requested workbook - - - Please remember they are all in separate instances of Excel.

Since the code I'm using can determine if the requested workbook is already open, I think there has to be a way to activate that workbook.

View 14 Replies


ADVERTISEMENT

Open Workbook In Seperate Program

Jun 22, 2007

I want to know if when you open an excel file from the desktop is it possible to have that paticular file open in a new Excel program instead of one that is already opened. A more specific senerio is that I have Excel running a program and if i open from the desktop it opens it in that paticular excel program. I can open excel a second time and have to seperate excel programs running. Is it possible that when I open a paticular excel sheet from the desktop that it opens in a new excel program besides the one that is already running.

View 3 Replies View Related

Activate Another Open Workbook

Aug 15, 2008

I have 2 workbooks open

Book1 has a call to ChangeBook()
Book2 is empty

Function ChangeBook()
Application.Workbooks("Book2.xls").Activate
End Function

ChangeBook() is located in a .xla file loaded on Excel launch.

Calling the function from Book1 does not cause Book2 to activate.

Running the function via the F5 key in the IDE works fine.

I am modifying existing routines that have problems and being able to activate certain books at will would make the changes much easier.

View 9 Replies View Related

Activate Sheet After Open Workbook..?

Jan 26, 2010

On a command button in a userform, I have this code to open another workbook:

View 2 Replies View Related

Workbooks.Open Does Not Activate The Workbook

Nov 5, 2008

I have a workbook containing macros that opens a second one (no macros) and does some 'data mining'.

The following VBA is used for that (I use this code on dozen of files and it has always worked, except here):

Set WshShell = CreateObject("WScript.Shell")
ChDir (WshShell.SpecialFolders("MyDocuments"))
BladNaam = Application.GetOpenFilename("Excel File, *.xls", , "Excel")
Workbooks.Open FileName:=BladNaam
TabNaam = ActiveSheet.Name

The problem is that most of the time the newly opened workbook is NOT activated (i.e put on top) and thus the rest of the code is executed on the wrong workbook...

If I put in a Msgbox(ActiveWorkbook.Name) 9 out of 10 times the active workbook is the initial one and not the one that was opened by the code.

tried replacing Active.Workbook with wb (dim wb as workbook).
tried to wait-a-few-seconds in between code
tried renaming

View 9 Replies View Related

Activate Open Workbook From Cell Reference

Aug 20, 2008

activate an open workbook based on the workbook name that is typed into a cell that is a named range?

So, I keep wanting to do this:
Windows.Activate Filename:=Range("MyRange")

Because this works:
Workbooks.Open Filename:=Range("MyRange")

View 9 Replies View Related

Pasting Charts Between 2 Instances Copies Macro Code Into Hidden Workbook

Apr 13, 2008

Consider two instances of Excel - one with a workbook containing a chart and some VBA code, the other containing a blank workbook. When I paste a chart from the first instance of Excel to the other, all the VBA code from the original workbook is also pasted into a new third hidden workbook in the second instance of Excel! If that weren't weird enough ON WINDOWS XP (but not Windows 2000) if the VBA code included WorkbookOpen or AutoOpen this code is executed in the second instance of Excel, which of course fails if it references sheets that only existed in the workbook open in the first instance of Excel! This is the first time I've seen the same version of Excel do different things on different versions of Windows! Example attached - What's going on!? Auto Merged Post Until 24 Hrs Passes;...note: this does not happen when pasting charts between workbooks open in the SAME instance of Excel

View 6 Replies View Related

Check To See If File Is Open, And If It Is Open, Activate It

May 14, 2009

I have two workbooks. One is a no-nonsense form interface that my bosses will use to enter safety information. I'll call this workbook "Form". This file is stored locally on each of their computers. The other workbook is stored on a common drive. I'll call it "Master".

When my bosses fill out the Form and click "Submit", the Master file is opened, and certain cells are populated based on information entered in the Form. This is the code I am using to make this happen:

View 5 Replies View Related

MacRO: Check If WorkBook Open. If Not, Open It.

Sep 27, 2006

I did a macro on my mac to transfer a sheet from one workbook to another worbook. It works very well when the destination workbook is open. Therefore I wanted to add some piece of code to check if the destination workbook is open. If not then I wanted the macro to open it before tranfering the sheet. Here is the code I´m using for tranfering the sheet

Sub Transfer_Sluttet()
If ActiveSheet.Index <> Sheets.Count Then
Application.DisplayAlerts = False
Set ws = ActiveSheet
Sheets(ws.Index + 1).Delete
ws.Move Before:=Workbooks("Sluttet.xls").Sheets("sheet2")
'Moves active sheet to beginning of named workbook.
'Replace Test.xls with the full name of the target workbook you want.
Application.DisplayAlerts = True
End If
End Sub

This is the type of macro I useually use on my pc to check if a workbook is open and if not then open it

If IsWorkbookOpened("Filename.xls", "C:Documents and ..................

View 3 Replies View Related

Modify Existing Macro To Copy To Different Workbook Instead Of Open Workbook?

Dec 7, 2012

Here's my macro:

Code:
Sub CopyRow()'
'Copies row to new sheet, highlights it, marks column 'A' as copied.
'
Dim cCell As Range
Set cCell = Selection.Cells(1, 1)
Selection.Copy
Sheets("Sheet2").Select
Rows("2:2").Select

[Code] .....

Is it possible to modify it to paste into a different workbook called c:filesDestination.xlsm, instead of the existing workbook (Source.xlsm)? The destination sheet name is the same (Sheet2). It's OK if both workbooks are open at the same time.

View 2 Replies View Related

Run Macro In Open Workbook When Workbook Becomes Activated Or Deactivated?

Apr 8, 2013

Is there a way to run a macro in an open workbook when the workbook becomes activated or deactivated? So if I have workbook A open with a macro in it and workbook B open as well, can I have the macro run on workbook A when that becomes the workbook I see on my screen?

View 2 Replies View Related

Multiple Instances (VBA To Open 3 Workbooks In Their Own Session/instance)

Feb 2, 2010

I'd like to use VBA to open 3 workbooks in their own session/instance/etc of Excel 2007. Ideally, there will be one main workbook, that upon opening will subsequently open the other 3 workbooks.

Also, when I open that first main workbook, I will obviously have to enable macros to get any code to run. Is there a way to carry this enabling of macros over to the other sessions to avoid having to enable macros in all 3 other workbooks? (Changing my security settings isn't an option)

View 3 Replies View Related

Activate Sheet And Disable Tabs On Open

Dec 6, 2008

I am trying to create an event macro that would deactivate column and row headers when the workbook is launched and activate a sheet. i am not managing to do this,

View 2 Replies View Related

Dynamic Workbook Within A Formula.: Look Up A Value Within A Seperate Workbook

Mar 27, 2009

I am creating a formula - that will look up a value within a seperate workbook. I want the workbook reference to change based on a cell which contains the date.

So workbook name is "Report 120309.xls"
Cell: A1 contains the date "120309"

Current formula ='[Report 120309.xls]Sheet 1'!$F$50. Can I replace the data within the formula with the date in the cell.

View 2 Replies View Related

Prompt Open Closed Workbook Then Copy Range And Paste Special Into Open Workbook

Apr 6, 2013

I have created a spreadsheet some time ago and have been asked to improve on it but I'm rusty with VBA.

I have an automated ordering system that saves each sent order as the date e.g "05-04-2013.xls" but the management team want a graph with the data for the last 4 weeks compared. I have created a seperate workbook called "consumables report.xls" which has a column with the products listed followed by columns "Quantity" and "cost" which is repeated for the 4 weeks of the month.

I want to add a button to prompt the user to choose the saved order e.g "05-04-2013.xls" (all orders saved in same directory) to copy and paste the quantity and cost columns (c8,D69) into "consumables report.xls". I got this to work earlier but it would only paste the formulas and not the values. So I need

A prompt to open workbook
Copy range (c8,d69)
Close work sheet
Paste special .value (c8,D69)

I dont care if it has to open the workbook to copy the data as this will only be used once a month so it dosnt matter how slow the code is.

week 1 week 2 week 3 week 4
Product
quantity
cost
quantity
cost
cost
quantity
cost

1
2
3
4
5
6
7
8

View 7 Replies View Related

Workbooks Take Long Time To Activate When Vb Editor Is Open

Mar 17, 2007

I have the VB Editor open and am manually activating different workbooks in Excel (with 20/25 modules each), the VB Editor goes through a process of maximising each and every module in the workbook I have selected before I can edit any code or, indeed, do anything in the workbook. This process takes about 8-10 seconds every time I select a different workbook in excel! I have played around with the settings "Full Module View" in the options section of the VB editor, but to no effect.

View 3 Replies View Related

2 Instances Of 2007 Slow To Open A File By Double-clicking And Entering From Windows Explorer

Sep 20, 2007

i use excel 2007, it s slow to open a file by double-clicking and entering from windows explorer, by googling i fould a fix by adding "%1" at the end of command in "Application used to perform action" (folder options/file types/xls/advance/open). however, to open files in the same instance, i have to keep "DDE message" with [open("%1")]. With both "%1", excel now opens twice.
How to fix it?

View 3 Replies View Related

Open File Macro: Same Directory As Macro Workbook

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

Run Macro With More Than 1 Workbook Open

Apr 29, 2009

I currently have a macro set up to run once a workbook is saved/ closed. This works fine unless tehre is more than one workbook open. When I try it with more than 1 different workbook open I get a run error.

My code begins:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

and then performs the macro. I don't really want to specify the filename as this is liable to change. Is there anyway of adding a "this workbook" command to the text string, and if so where would it go?

View 10 Replies View Related

Macro To Open New Workbook

Dec 16, 2011

if workbook("Result") is not open then
add new workbook and name it "Result + date and time"
else activate workbook "Result"

View 3 Replies View Related

Run A Sub Or Function In A Seperate Workbook Using Vba

Jan 28, 2009

I've seen that you can set up a reference and that may be the only way, but my guess would be that it is not the only way.

I'd like to open and run a sub from a different workbook (in the same folder) using vba. For example, test1.xls would have a sub that would open test2.xls and run a sub from test2.xls before closing and returning to test1.xls.

View 9 Replies View Related

Copying Instances From One Workbook To Another

Jan 12, 2008

I have two workbooks, a "vehicle workbook" and an "Oil sample" workbook. I'm trying to write a macro that will store the ID of the vehcile in "vehicle workbook" into a varible, open the Oil sample workbook and find instances of the vehicle ID in column B. Next it will copy the entire row, and paste it back into the "vehicle workbook". I've taken some code and modified it to try and make it work but I'm running into problems. I'm very much a newbie to excel and macro's and am learning little by little. This is what I have so far...

Option Explicit
Sub btnFind_Click()
Application. ScreenUpdating = False
Application.EnableEvents = False
Dim vehicleNumber As Variant
Dim sourceLocation As String
Dim sourceFileName As String
Dim fileName As String
Dim vehicleFileName As String
'referencing the workbook location of the vehicle
vehicleFileName = ActiveWorkbook.FullName
MsgBox (vehicleFileName)
'copying the vehicle number into memory ie.EFQRTS67WZ100121
vehicleNumber = ActiveSheet. Range("A13").Value.....................

View 5 Replies View Related

Start Macro At Workbook Open

Nov 14, 2008

I found an outlook plugin that saves any incoming emails as text. It also has an option to run an exe or bat file on saveing the email to text. I have a macro in a worksheet that will process the email to a database and send out a response.

What I am trying to figure out is how to run the macro in the worksheet whenever an incoming email is saved. So I have the 2 components that I need, I just need to tie them together so that everything is automated.

Does anyone know how to achieve this? Can I use a batch file to open an excel workbook and run a macro? Or can I create a standalone macro (outside of excel) that can open the excel file and run the macro.

View 3 Replies View Related

Open Workbook Macro Only Runs Once..

Jun 30, 2009

i have a button on my workbook1 that opens another workbook (lets call it workbook2) and automatically runs a macro on opening it. Once opened i have a button on workbook2 to close itself. I then go back to see workbook1. This all works but then when i click on the button to open the workbook2 again it opens but the macro does not run.

View 4 Replies View Related

Trying To Get A Workbook.Open Macro To Work

May 29, 2007

I'm trying to get a Workbook.Open macro to work. I"m using the exact name for the location. For example:

Workbooks.Open ("O:AdministrationPM Weekly's2007PMWeeklyWE")

My other locations are working fine. For example I am using:

Workbooks.Open ("O:AdministrationDCS Week EndingStats"

View 9 Replies View Related

LastRow Does Not Seem To Look In The Workbook That The Macro Has Open

Jan 15, 2008

The problem is that LastRow does not seem to look in the workbook that the macro has open, and always returns a value of 1. If I place the sheet that i want to run the macro on, in the workbook that contains the macro there is no problem. What do I need to do to fix this.

LoopCount = Sheets("Dates").Range("A" & Rows.Count).End(xlUp).Row
rng = 2
i = 1
Do
Selection.AutoFilter Field:=7, Criteria1:="=" & Sheets("Dates").Range("A" & rng), Operator:=xlAnd
z = Range("B" & Rows.Count).End(xlUp).Row
For y = 2 To z
If Rows(y).Hidden = False Then Exit For
Next y
MsgBox y
MsgBox z
Range("H" & z).Formula = "=Countif($A$" & y & ":$A$" & z & ",A" & z & ")"
Range("H" & z).Copy Destination:=Range("H" & y & ":H" & z)
rng = rng + 1
i = i + 1
Loop Until i = LoopCount

View 9 Replies View Related

Macro: Write To Another Open Workbook

Nov 17, 2006

Trying to Figure out how to open another Excel (based on an template). From Dok1 I start A Macro To Open Doc2.xlt (using Workbooks.Add). Then I Would Like To Write to a Cell But I end Up Writing To The Cells Of Dok1 Even Though It's Dok2 That Is Visable and Activated. I allso do this with word, I have no problems there (Excel to Word) But there i'm using Bookmarks To transfer data. As far as i know , you can't use bookmarks in excel.

View 4 Replies View Related

Check If A Workbook Is Open Macro

Jun 21, 2007

I am looking to check if its open, if it is, then copy the row, if not, then close it.

I am still new to vb, so learning as I go, but looked at many other posts, and there are so many ways i have seen to open one, I'm not sure which is the best, and none that I have seen show me if they check if its open.

View 9 Replies View Related

Macro To Open Workbook With Password

Jul 25, 2007

I have a workbook with the following

Sub Workbook_Open()
Sheets("Occ-Rent-Concess Worksheet").Select
ActiveSheet.Unprotect Password:="pass"
ActiveSheet.Select
Cells.Locked = True
ActiveSheet.Protect Password:="pass"
pass:
UserName = InputBox("Enter Log On Name to Continue..............................................

This code opens a msgbox that asks for a password and then unlocks certain cells based on what the password is. I have 140 of these workbooks. I need to be able to open them all and change one cell in each file, save it and close. I've gotten the macro written to open, change and save the files, but I am still having to type the 'password' 140 times. Is there a way to bypass it?

View 4 Replies View Related

Open/Add New Workbook Macro Code

May 12, 2008

I am trying to write code to open a new (blank) workbook while in an existing workbook (I am then going to pass data between the two which is easy). When I try to record the code to get the syntax for opening a new workbook it will not record any code. I also need to name the new workbook based on text in a cell in the existing workbook. I just saw before posting this that the code;

workbooks.add

will open a new workbook now I just need to name the new workbook based on text in my existing workbook.

View 2 Replies View Related







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