ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   print from listbox (https://www.excelbanter.com/excel-programming/310146-print-listbox.html)

misscrf[_3_]

print from listbox
 
I am so excited! I have automated charts in excel, so that the user ca
open to a menu worksheet, refresh all of the chart's data (wit
parameter) and preview and print them.

I am learning vb as I go, and I don't think I am do TOO bad. Anyway,
wanted to make a user form in the vb code to have a list box. I woul
make a 4th button on this menu sheet, so that the user can choose t
print just 1 or more chart, rather than all of them.

I created the list box, and populated it list. This is a multiselec
with checkboxes.

Private Sub UserForm_Initialize()
'The 1st list box contains 3 data columns
ListBox1.ColumnCount = 7

'Load integer values into first column of MyArray


'Load columns 2 and three of MyArray
MyArray(0, 0) = "Domestic Long Distance"
MyArray(1, 0) = "Toll Free"
MyArray(2, 0) = "Directory Assistance"
MyArray(3, 0) = "Local"
MyArray(4, 0) = "International"
MyArray(5, 0) = "Calling Cards"
MyArray(6, 0) = "Usage Type"


'Load data into ListBox1
ListBox1.List() = MyArray

End Sub


Now I will have a command button on the user form to print the selecte
charts. My question is, how do I do that?

I have looked for the code, but I am not finding a direct answer.
figure I need to declare each row value = to the chart that I have, an
then for each value selected print that chart. Right? :confused:

Any help on this code would be great!
Thanks all.

This is fun. I want to be a vb expert! hehehehe
misscrf

Management is doing things right, leadership is doing the right thing

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

print from listbox
 
PrivateSub Commandbutton1_Click()
With listbox1
for i = 0 to .listcount - 1
if .selected(i) then
for each chtObj in Activesheet.ChartObjects
if lcase(chtObj.Chart.Name) = lcase(.list(i)) then
chtObject.Chart.Printout
Exit for
end if
Next
end if
Next
End with
End Sub

Assumes the chart name is the same as the entries in the listbox.
Untested, but this should be close.
--
Regards,
Tom Ogilvy


"misscrf " wrote in message
...
I am so excited! I have automated charts in excel, so that the user can
open to a menu worksheet, refresh all of the chart's data (with
parameter) and preview and print them.

I am learning vb as I go, and I don't think I am do TOO bad. Anyway, I
wanted to make a user form in the vb code to have a list box. I would
make a 4th button on this menu sheet, so that the user can choose to
print just 1 or more chart, rather than all of them.

I created the list box, and populated it list. This is a multiselect
with checkboxes.

Private Sub UserForm_Initialize()
'The 1st list box contains 3 data columns
ListBox1.ColumnCount = 7

'Load integer values into first column of MyArray


'Load columns 2 and three of MyArray
MyArray(0, 0) = "Domestic Long Distance"
MyArray(1, 0) = "Toll Free"
MyArray(2, 0) = "Directory Assistance"
MyArray(3, 0) = "Local"
MyArray(4, 0) = "International"
MyArray(5, 0) = "Calling Cards"
MyArray(6, 0) = "Usage Type"


'Load data into ListBox1
ListBox1.List() = MyArray

End Sub


Now I will have a command button on the user form to print the selected
charts. My question is, how do I do that?

I have looked for the code, but I am not finding a direct answer. I
figure I need to declare each row value = to the chart that I have, and
then for each value selected print that chart. Right? :confused:

Any help on this code would be great!
Thanks all.

This is fun. I want to be a vb expert! hehehehe
misscrf

Management is doing things right, leadership is doing the right things


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 09:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com