[mso] macro problem

  • From: Nikunj Shah <catchnikunj@xxxxxxxxx>
  • To: mso@xxxxxxxxxxxxx
  • Date: Mon, 19 Aug 2002 09:12:44 -0700 (PDT)

I have an excel workbook on the desktop (a.xls) that
contains 20 to
30 sheets. Every individual sheet is a form. The user
may need any of
the form in the workbook according to his
requirements.  I have
recorded a macro that enables the user to copy a
predetermined sheet
to the current workbook. The macro is stored in
personal.xls, so that
the user may run it from any workbook. After editing
the macro and
racking my brains over it (I DO NOT KNOW ANY VB
PROGRAMMING CODE, I
HAVE SIMPLY TRIED TO UNDERSTAND BY THE HELP FILES),
the code looks as
under

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 8/8/02 by comp1
'
' Keyboard Shortcut: Ctrl+m
'
    ChDir "C:\WINDOWS\Desktop"
    Workbooks.Open
FileName:="C:\WINDOWS\Desktop\a.xls"
    Sheets("Sheet1").Select
    Sheets("Sheet1").Copy Before:=Worksheets("Sheet1")



End Sub





However, I face the following problems
1. the sheet does not get copied in the current
workbook i.e. the
workbook from which the macro is run and in which the
user desires to
copy the predetermined sheet. Instead, the sheet is
copied in the
same workbook i. e. a.xls. I think that there is some
problem in
second last Line of the above code. How does on solve
this????
2. The macro opens the worksheet "a.xls", when the
first time the
macro is run. So when the second time the macro is
run, it gives a
message saying " a.xls is already open??". How should
one take care
of this problem. Should the file from which the sheet
is copied (i.e.
a.xls) be closed by the macro itself after every time
the macro is
run, or should the macro first check if the file is
already open and
the work accordingly so as to prevent the message. In
either case,
how????
I don't want to use templates for each and every
individual sheet in
the workbook for the sake of convenc and quickness of
operation.


Thanks so much for any help

Nikunj S.




__________________________________________________
Do You Yahoo!?
HotJobs - Search Thousands of New Jobs
http://www.hotjobs.com
*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or 
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, send an email to 
mso-request@xxxxxxxxxxxxx?Subject=unsubscribe

Or, visit the group's homepage and use the dropdown menu.  This will also allow 
you to change your email settings to digest or vacation (no mail).
//www.freelists.org/webpage/mso

To be able to use the files section for sharing files with the group, send a 
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with 
instructions.  Once you are a member of the files group, you can go here to 
upload/download files:
http://www.smartgroups.com/vault/msofiles
*************************************************************

Other related posts:

  • » [mso] macro problem