Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro from a different xls file run, still says file in use

Hello,

my .xls file runs a macro from a different file via
"'M:\month\2000\kkhelp.xls'!project.project"

Usually, when the macro has done its magic (exporting data etc), the macro
saves the .xls file and closes it (and itself with it, of course). If the
user hasnt inputted enough data to export, the macro tells the user that and
ends via "exit sub". The problem is, that if this case occurs, the kkhelp.xls
file is still open, even if no macros are running anymore. If someone else
tries to run the macro while the first user is fixing his input data, the
macro will bitch about the kkhelp.xls file being in use.

Is there any way to stop this from happening, for example automatically
close the kkhelp.xls when there are no macros running?

Help appreciated,
Amos
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro from a different xls file run, still says file in use

Rather than using exit sub by itself

Rather than (this is pseudo code)

if not enough data then
msgbox "not enough"
exit sub
End if

use something like

If not enough data then
msgbox "not enough"
Close the kkelp.xls
end if

Assuming kkhelp.xls is the workbook containing the macro
as soon as the workbook closes, the macro halts.

--
Regards,
Tom Ogilvy


"A. Ahola" wrote in message
...
Hello,

my .xls file runs a macro from a different file via
"'M:\month\2000\kkhelp.xls'!project.project"

Usually, when the macro has done its magic (exporting data etc), the macro
saves the .xls file and closes it (and itself with it, of course). If the
user hasnt inputted enough data to export, the macro tells the user that

and
ends via "exit sub". The problem is, that if this case occurs, the

kkhelp.xls
file is still open, even if no macros are running anymore. If someone else
tries to run the macro while the first user is fixing his input data, the
macro will bitch about the kkhelp.xls file being in use.

Is there any way to stop this from happening, for example automatically
close the kkhelp.xls when there are no macros running?

Help appreciated,
Amos



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro from a different xls file run, still says file in use



"Tom Ogilvy" wrote:

Rather than using exit sub by itself

Rather than (this is pseudo code)

if not enough data then
msgbox "not enough"
exit sub
End if

use something like

If not enough data then
msgbox "not enough"
Close the kkelp.xls
end if

Assuming kkhelp.xls is the workbook containing the macro
as soon as the workbook closes, the macro halts.

--
Regards,
Tom Ogilvy


Makes sense, I thought that whenever a file with macro references to a
another file is opened, the other files are opened as well. This isnt the
case, the other files are opened when the macros are called, and the macro
itself must handle closing the file with the macro.

Anyway, your way worked, thanks for the help.

-Amos



"A. Ahola" wrote in message
...
Hello,

my .xls file runs a macro from a different file via
"'M:\month\2000\kkhelp.xls'!project.project"

Usually, when the macro has done its magic (exporting data etc), the macro
saves the .xls file and closes it (and itself with it, of course). If the
user hasnt inputted enough data to export, the macro tells the user that

and
ends via "exit sub". The problem is, that if this case occurs, the

kkhelp.xls
file is still open, even if no macros are running anymore. If someone else
tries to run the macro while the first user is fixing his input data, the
macro will bitch about the kkhelp.xls file being in use.

Is there any way to stop this from happening, for example automatically
close the kkhelp.xls when there are no macros running?

Help appreciated,
Amos




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro from a different xls file run, still says file in use

If you actually create a reference to the file (in the VBE) in
Tools=References, then the referenced workbook is opened with the
referencing file, but not just because you refer to it in your code.

--
Regards,
Tom Ogilvy


"A. Ahola" wrote in message
...


"Tom Ogilvy" wrote:

Rather than using exit sub by itself

Rather than (this is pseudo code)

if not enough data then
msgbox "not enough"
exit sub
End if

use something like

If not enough data then
msgbox "not enough"
Close the kkelp.xls
end if

Assuming kkhelp.xls is the workbook containing the macro
as soon as the workbook closes, the macro halts.

--
Regards,
Tom Ogilvy


Makes sense, I thought that whenever a file with macro references to a
another file is opened, the other files are opened as well. This isnt the
case, the other files are opened when the macros are called, and the macro
itself must handle closing the file with the macro.

Anyway, your way worked, thanks for the help.

-Amos



"A. Ahola" wrote in message
...
Hello,

my .xls file runs a macro from a different file via
"'M:\month\2000\kkhelp.xls'!project.project"

Usually, when the macro has done its magic (exporting data etc), the

macro
saves the .xls file and closes it (and itself with it, of course). If

the
user hasnt inputted enough data to export, the macro tells the user

that
and
ends via "exit sub". The problem is, that if this case occurs, the

kkhelp.xls
file is still open, even if no macros are running anymore. If someone

else
tries to run the macro while the first user is fixing his input data,

the
macro will bitch about the kkhelp.xls file being in use.

Is there any way to stop this from happening, for example

automatically
close the kkhelp.xls when there are no macros running?

Help appreciated,
Amos






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
2007 Macro to Open File, Delete Contents, Save New File Flintstone[_2_] Excel Discussion (Misc queries) 2 February 1st 10 11:25 PM
Macro to call a file that has a auto open macro in the file itself [email protected] Excel Programming 1 August 5th 05 06:39 AM
Macro to insert values from a file and save another sheet as a .txt file Frank[_16_] Excel Programming 2 August 28th 03 01:07 AM
Automate open file, update links, run macro, close and save file Geoff[_7_] Excel Programming 2 August 26th 03 10:13 PM


All times are GMT +1. The time now is 07:51 PM.

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

About Us

"It's about Microsoft Excel"