#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Exce Macros

Sorry there is a small goof in my original code. Try this...

Sub ModifyOtherBook()
Dim wbkTarget As Workbook

On Error Resume Next
Set wbkTarget = Workbooks("That.xls")
On Error GoTo 0

If wbkTarget Is Nothing Then Set wbkTarget = Workbooks.Open("C:\That.xls")

wbkTarget.Sheets("Sheet1").Range("A1").Value = "Tada"
End Sub
--
HTH...

Jim Thomlinson


"LPS" wrote:

Thank you. I will experiment with this and I'm sure it will help.
--
LPS


"Jim Thomlinson" wrote:

Here is a very basic example. It modifies a workbook called That.xls. It
first checks if the book is open. if not it opens it. There is a workbook
object called wbkTarget that gives you a reference to the workbook we are
manipulating. The code is running in "ThisWorkbook".

Sub ModifyOtherBook()
Dim wbkTarget As Workbook

On Error Resume Next
Set wbkTarget = Workbooks("That.xls")
On Error GoTo 0

If wbkTarget Is Nothing Then Workbooks.Open ("C:\That.xls")

wbkTarget.Sheets("Sheet1").Range("A1").Value = "Tada"
End Sub
--
HTH...

Jim Thomlinson


"LPS" wrote:

Hi Jim. Thank you for such a fast response. I want to be able to manipulate
a second workbook from a macro I start in the first workbook. It doesn't
matter where the execution ends.
--
LPS


"Jim Thomlinson" wrote:

Yes...ish but we need a little more clarification. Do you want to

1. manipulate another workbook
2. run code that exists in another workbook

Bare in mind the the thread of execution will always end in the workbook
that began the process, but that workbook does not need to be the active
workbook when the code ends.
--
HTH...

Jim Thomlinson


"LPS" wrote:

Using Excel 2000 can you create a macro that works across more than one
workbook? For example, can a macro start running in one workbook and finish
in another? If so, is there any special code or actions you need to do to
make it work?

Thanks,
--
LPS

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exce Formating Laura1 via OfficeKB.com Excel Worksheet Functions 7 May 3rd 09 03:34 AM
How do I keep a running average of a row in exce; kent Excel Discussion (Misc queries) 1 August 9th 06 07:59 AM
Exce file security illini0513 Excel Discussion (Misc queries) 0 December 29th 05 01:53 PM
stopping the link of macros in one workbook with every other exce. KyWilde Excel Discussion (Misc queries) 0 March 10th 05 06:35 PM
stopping the link of macros in one workbook with every other exce. KyWilde Excel Discussion (Misc queries) 0 March 10th 05 06:35 PM


All times are GMT +1. The time now is 08:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"