Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Macros will not run with two Excel applications open

After 10 months of writing, my program finally is finished! I have an
issue, though (I guess a program is never really finished...) I send
my Excel program out to various unskilled people to use to keep score
at school events. If they have a second Exel application open, the
Macros seem to not know which program they are attached to, and my
program crashes every time.

Is there any way to tie the macros in my program to my program? I
cannot use the program name in the Macro lines, even though the
program name is constantly changed by the various users. Even if the
user makes a copy of the program (as they are instructed to do as a
backup), and both the copy and the original are active at the same
time, crash! I think there is probably a simple solution, but I have
no idea what it is. Perhaps there is some way to have the program
read its name and tie the macros to the name when it is opened? I do
not know how to find this information without help. Could someone
guide me on this one? Your help on this group is always greatly
appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Macros will not run with two Excel applications open

thats no surprise. Its impossible to build "idiot" proof applications

usually though, this cab be avoide through correct use of worksheets etc

so not
(1)
Selection.Clear

but
(2) Thisworkbook.worksheets("sheet1").range("B5:G5").C learContents


with (1) whatever was actually selectyed would be cleared while with (2)
onlt one specific range would clear

so if yuor code asks the user to open a workbook, set it to a workbook oblect


eg

Dim wb As Workbook
Set wb = Workbooks.Open(Application.GetOpenFilename())

now you have a handle, wb , on their workbook it ehey open another, your
code referencing wb whould not break
thats teh idea...if its taken 9 months, then wow, you may have a lot to change











"RJQMAN" wrote:

After 10 months of writing, my program finally is finished! I have an
issue, though (I guess a program is never really finished...) I send
my Excel program out to various unskilled people to use to keep score
at school events. If they have a second Exel application open, the
Macros seem to not know which program they are attached to, and my
program crashes every time.

Is there any way to tie the macros in my program to my program? I
cannot use the program name in the Macro lines, even though the
program name is constantly changed by the various users. Even if the
user makes a copy of the program (as they are instructed to do as a
backup), and both the copy and the original are active at the same
time, crash! I think there is probably a simple solution, but I have
no idea what it is. Perhaps there is some way to have the program
read its name and tie the macros to the name when it is opened? I do
not know how to find this information without help. Could someone
guide me on this one? Your help on this group is always greatly
appreciated.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Macros will not run with two Excel applications open

On Sep 25, 11:37*am, Patrick Molloy
wrote:
thats no surprise. Its impossible to build "idiot" proof applications

usually though, this cab be avoide through correct use of worksheets etc

so not
(1)
Selection.Clear

but
(2) Thisworkbook.worksheets("sheet1").range("B5:G5").C learContents

with (1) whatever was actually selectyed would be cleared while with (2)
onlt one specific range would clear

so if yuor code asks the user to open a workbook, set it to a workbook oblect

eg

Dim wb As Workbook
Set wb = Workbooks.Open(Application.GetOpenFilename())

now you have a handle, wb , on their workbook it ehey open another, your
code referencing wb whould not break
thats teh idea...if its taken 9 months, then wow, you may have a lot to change



"RJQMAN" wrote:
After 10 months of writing, my program finally is finished! *I have an
issue, though (I guess a program is never really finished...) *I send
my Excel program out to various unskilled people to use to keep score
at school events. *If they have a second Exel application open, the
Macros seem to not know which program they are attached to, and my
program crashes every time.


Is there any way to tie the macros in my program to my program? *I
cannot use the program name in the Macro lines, even though the
program name is constantly changed by the various users. Even if the
user makes a copy of the program (as they are instructed to do as a
backup), and both the copy and the original are active at the same
time, crash! * I think there is probably a simple solution, but I have
no idea what it is. * Perhaps there is some way to have the program
read its name and tie the macros to the name when it is opened? *I do
not know how to find this information without help. Could someone
guide me on this one? *Your help on this group is always greatly
appreciated.- Hide quoted text -


- Show quoted text -


In other words, I just need to insert "ThisWorkbook." in front of the
word "Sheets" or "Worksheets" in each line of code in VBA, and that
should make it work. It did a quick test, and it seemed to do it -
but I wanted to be sure. That can be done with a find-replace, and
should be pretty simple to implement. If that is correct, I will do
it today! And I can take out those warning messages that I had in
there too. Many thanks.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Macros will not run with two Excel applications open

Thisworkbook always refers to the workbook that is running the code. The
parent object of thisworkbook is Application which is the instance of XL that
is running the code.

If you do not explicitly refer to thisworkbook then the default parent is
activeworkbook (depending where the code resides). While I avoid multiple
instances of XL so I can not really comment I suspect that your issue
revolves from here.

In short... Definintly use thisworkbook...
--
HTH...

Jim Thomlinson


"RJQMAN" wrote:

On Sep 25, 11:37 am, Patrick Molloy
wrote:
thats no surprise. Its impossible to build "idiot" proof applications

usually though, this cab be avoide through correct use of worksheets etc

so not
(1)
Selection.Clear

but
(2) Thisworkbook.worksheets("sheet1").range("B5:G5").C learContents

with (1) whatever was actually selectyed would be cleared while with (2)
onlt one specific range would clear

so if yuor code asks the user to open a workbook, set it to a workbook oblect

eg

Dim wb As Workbook
Set wb = Workbooks.Open(Application.GetOpenFilename())

now you have a handle, wb , on their workbook it ehey open another, your
code referencing wb whould not break
thats teh idea...if its taken 9 months, then wow, you may have a lot to change



"RJQMAN" wrote:
After 10 months of writing, my program finally is finished! I have an
issue, though (I guess a program is never really finished...) I send
my Excel program out to various unskilled people to use to keep score
at school events. If they have a second Exel application open, the
Macros seem to not know which program they are attached to, and my
program crashes every time.


Is there any way to tie the macros in my program to my program? I
cannot use the program name in the Macro lines, even though the
program name is constantly changed by the various users. Even if the
user makes a copy of the program (as they are instructed to do as a
backup), and both the copy and the original are active at the same
time, crash! I think there is probably a simple solution, but I have
no idea what it is. Perhaps there is some way to have the program
read its name and tie the macros to the name when it is opened? I do
not know how to find this information without help. Could someone
guide me on this one? Your help on this group is always greatly
appreciated.- Hide quoted text -


- Show quoted text -


In other words, I just need to insert "ThisWorkbook." in front of the
word "Sheets" or "Worksheets" in each line of code in VBA, and that
should make it work. It did a quick test, and it seemed to do it -
but I wanted to be sure. That can be done with a find-replace, and
should be pretty simple to implement. If that is correct, I will do
it today! And I can take out those warning messages that I had in
there too. Many thanks.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Macros will not run with two Excel applications open

On Sep 25, 1:28*pm, Jim Thomlinson <James_Thomlin...@owfg-Re-Move-
This-.com wrote:
Thisworkbook always refers to the workbook that is running the code. The
parent object of thisworkbook is Application which is the instance of XL that
is running the code.

If you do not explicitly refer to thisworkbook then the default parent is
activeworkbook (depending where the code resides). While I avoid multiple
instances of XL so I can not really comment I suspect that your issue
revolves from here.

In short... Definintly use thisworkbook...
--
HTH...

Jim Thomlinson



"RJQMAN" wrote:
On Sep 25, 11:37 am, Patrick Molloy
wrote:
thats no surprise. Its impossible to build "idiot" proof applications


usually though, this cab be avoide through correct use of worksheets etc


so not
(1)
Selection.Clear


but
(2) Thisworkbook.worksheets("sheet1").range("B5:G5").C learContents


with (1) whatever was actually selectyed would be cleared while with (2)
onlt one specific range would clear


so if yuor code asks the user to open a workbook, set it to a workbook oblect


eg


Dim wb As Workbook
Set wb = Workbooks.Open(Application.GetOpenFilename())


now you have a handle, wb , on their workbook it ehey open another, your
code referencing wb whould not break
thats teh idea...if its taken 9 months, then wow, you may have a lot to change


"RJQMAN" wrote:
After 10 months of writing, my program finally is finished! *I have an
issue, though (I guess a program is never really finished...) *I send
my Excel program out to various unskilled people to use to keep score
at school events. *If they have a second Exel application open, the
Macros seem to not know which program they are attached to, and my
program crashes every time.


Is there any way to tie the macros in my program to my program? *I
cannot use the program name in the Macro lines, even though the
program name is constantly changed by the various users. Even if the
user makes a copy of the program (as they are instructed to do as a
backup), and both the copy and the original are active at the same
time, crash! * I think there is probably a simple solution, but I have
no idea what it is. * Perhaps there is some way to have the program
read its name and tie the macros to the name when it is opened? *I do
not know how to find this information without help. Could someone
guide me on this one? *Your help on this group is always greatly
appreciated.- Hide quoted text -


- Show quoted text -


In other words, I just need to insert "ThisWorkbook." in front of the
word "Sheets" or "Worksheets" in each line of code in VBA, and that
should make it work. * It did a quick test, and it seemed to do it -
but I wanted to be sure. *That can be done with a find-replace, and
should be pretty simple to implement. *If that is correct, I will do
it today! *And I can take out those warning messages that I had in
there too. *Many thanks.- Hide quoted text -


- Show quoted text -


Many thanks to you both.

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
Can't open Excel files from other applications Paul Excel Discussion (Misc queries) 1 February 10th 09 01:43 PM
Open non MS applications Frankie Excel Programming 4 August 23rd 06 12:04 AM
check Open Excel applications Zurn[_56_] Excel Programming 0 May 8th 06 07:29 AM
Crossing applications with macros Rominall Excel Programming 0 February 14th 06 02:22 PM
macros for other applications Douvid Excel Programming 3 July 14th 03 02:44 PM


All times are GMT +1. The time now is 01:13 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"