G
giancarp
Hi all,
I'm having a problem with Excel and I haven't been able to find a
solution.
What I'm doing is copying some data from a hidden worksheet using VBA.
This is done very easily. The problem is that Excel copies, together
to the data, also the state of the worksheet (Visible/Hidden/
VeryHidden), and this is causing me headaches. Let me give you the
algorithm to reproduce my problem.
1. Open two indipendent session of Excel. With my current settings it
opens it with three worksheets: Sheet1, Sheet2 and Sheet3.
2. On the first session type a number in cell Sheet1!A1 (for example
878)
3. Press Alt-F11to enter the VBA Editor and change the property
"Visible" for Sheet1 to be xlSheetVeryHidden
4. From the Immediate window type: Sheet1.Range("A1").Copy (this will
copy the content of cell A1 into the clipboard. Unfortunately it
copies something more than that).
5. Go on the second session of Excel and press Ctrl^V (or Paste from
the Edit menu).
6. On the second session of Excel click on the tab of the second
worksheet (Sheet2). You will see that Sheet1 has disappeared.
7. Open Visual Basic Editor on the second session of Excel, and if you
check, the Sheet1 still exists but it is VeryHidden.
The same happens if the source sheet is only Hidden, and it suggests
to me that Sheet1.Range("A1").copy doesn't only copy information about
the current cell, but also other information about the worksheet and
this is where it gets nasty for me. My application generates some data
in a hidden worksheet that the user can export by copying it to the
clipboard (using a button provided). If at that stage the user copies
the data to another session of Excel (which is quite a reasonable
thing to do), the worksheet disappears and the user panics thinking
that all this work has been lost.
And unfortunately, since after the copy everything is in the user's
hands, I cannot force any defensive action at the time the data is
copied (e.g. PasteSpecial->Values), but I need to find a work-around
to the "sheet1.range("A1").copy.
Interestingly enough, this only happens if the data is copied from one
session of Excel to another. Copying and pasting "from and to" the
same workbook or "from and to" two different workbooks open in the
same Excel session works normally as expected.
Any ideas? thank you very much
gc
I'm having a problem with Excel and I haven't been able to find a
solution.
What I'm doing is copying some data from a hidden worksheet using VBA.
This is done very easily. The problem is that Excel copies, together
to the data, also the state of the worksheet (Visible/Hidden/
VeryHidden), and this is causing me headaches. Let me give you the
algorithm to reproduce my problem.
1. Open two indipendent session of Excel. With my current settings it
opens it with three worksheets: Sheet1, Sheet2 and Sheet3.
2. On the first session type a number in cell Sheet1!A1 (for example
878)
3. Press Alt-F11to enter the VBA Editor and change the property
"Visible" for Sheet1 to be xlSheetVeryHidden
4. From the Immediate window type: Sheet1.Range("A1").Copy (this will
copy the content of cell A1 into the clipboard. Unfortunately it
copies something more than that).
5. Go on the second session of Excel and press Ctrl^V (or Paste from
the Edit menu).
6. On the second session of Excel click on the tab of the second
worksheet (Sheet2). You will see that Sheet1 has disappeared.
7. Open Visual Basic Editor on the second session of Excel, and if you
check, the Sheet1 still exists but it is VeryHidden.
The same happens if the source sheet is only Hidden, and it suggests
to me that Sheet1.Range("A1").copy doesn't only copy information about
the current cell, but also other information about the worksheet and
this is where it gets nasty for me. My application generates some data
in a hidden worksheet that the user can export by copying it to the
clipboard (using a button provided). If at that stage the user copies
the data to another session of Excel (which is quite a reasonable
thing to do), the worksheet disappears and the user panics thinking
that all this work has been lost.
And unfortunately, since after the copy everything is in the user's
hands, I cannot force any defensive action at the time the data is
copied (e.g. PasteSpecial->Values), but I need to find a work-around
to the "sheet1.range("A1").copy.
Interestingly enough, this only happens if the data is copied from one
session of Excel to another. Copying and pasting "from and to" the
same workbook or "from and to" two different workbooks open in the
same Excel session works normally as expected.
Any ideas? thank you very much
gc