how to print charts from protected and shared workbook?

N

nebsrc

The code bellow will print preview all charts from active
sheet only if workbook is in exclusive mode (used by one
user).
Because i want to place my workbook onto network drive to
be used by students i need to set workbook to shared mode.
but in this case code will print preview the last chart
that has been previewed when in exclusive mode.
i inserted msgbox within for/next loop to get chart names
and indexes before preview and it displays corect names
but next line
mychart(x).chart.printpreview displays the last chart that
has been displayed when in exclusive mode.

please any help would be appriciated
thanks,

Private Sub cmd_Click()
Dim myChart As ChartObjects
Dim X As Integer
Dim ChartList As Integer
Dim nm As String, mi As Long
Dim i As Integer
ChartList = ActiveSheet.ChartObjects.Count
Set myChart = ActiveSheet.ChartObjects
For X = 1 To ChartList
nm = myChart(X).Chart.Name
'mi = myChart(x).Chart.Index
MsgBox "name is " & nm & " and index is " & mi
myChart(X).Chart.PrintPreview
Next
 
J

Jon Peltier

Unfortunately, sharing workbooks interferes with a lot of standard Excel
features.

Do you need to save the changes made by each student? If not, then save
the file not as shared but as read only.

If you have to share the workbook, you can only print preview the
individual charts if you use chart sheets, not embedded chart objects.
This amended code worked in this case:

Sub PrintCharts()
Dim myChart As Chart
Dim X As Integer
Dim nm As String, mi As Long
For Each myChart In ActiveWorkbook.Charts
nm = myChart.Name
mi = myChart.Index
MsgBox "name is " & nm & " and index is " & mi
myChart.PrintPreview
Next
End Sub

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top