View Single Post
  #7   Report Post  
Joseph Geretz
 
Posts: n/a
Default

Hi Stephen,

Actually I'm going to try this later on this evening, but with a slight
twist to what you propose. With the Tab Strip and Image Control approach,
I'm going to have to implement my own scroll bars and panning since the size
of the Worksheet image may very well exceed the size of the Image Control.
So I'd like to modify your suggested approach as follows:

In place of the Tab Strip and Image Control, I'll use a second copy of
Excel. When I open a worksheet in the hidden copy of excel, I'll create a
new workbook in the visible excel with the same number of sheets as the
hidden workbook has. Then I'll cycle through the hidden sheets and for each
sheet I'll take a snapshot of its image and paste it into the corresponding
sheet in the visible excel. For good measure, I can protect every sheet in
the visible excel.

If my concept is correct, the visible excel sheets should look virtually
identical to the hidden excel sheets except for the fact that they'll be
images which can't be modified.

If you have any code sample which shows how to paste from the clipboard to
the top left coordinate of a worksheet that will be a great help.

Thanks for your help!

- Joe Geretz -

"Stephen Bullen" wrote in message
...
Hi Joseph,

Or maybe there's an easier way to do what I'm trying to do. We're
implementing an Excel Viewer window inside our application. Right now
we're
actually using the Excel Viewer application, but it's klunky launching an
external application and then finding and embedding the window via API.
We'd
much prefer using Excel itself via automation but we're finding what
should
be a simple operation (setting the sheets to be read only) to be more
complex than we had anticipated. Unless I've missed something?


Hmmm, not easy! As you mentioned, there are lots of little gotchas to
contend
with, such as sheets already protected, and what about third-party activeX
controls on the sheets, that might not respond to a Locked property?

I would be tempted to use an image control and a tab strip, with Excel
automated in the background (never visible). When you load a workbook, at
tabs
to the tab strip for each (visible) sheet in the book; when a tab is
clicked,
use Sheet.UsedRange.CopyPicture to copy an image of it to the clipboard,
then
set the clipboard's image to the Image control. Whether you consider that
to be
more or less of a 'hack' than using the actual Viewer is a matter of
preference!

Regards

Stephen Bullen
Microsoft MVP - Excel
www.oaltd.co.uk