Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 219
  • Last Modified:

vb Print and Save Charts (urgent)!!

Here are my questions :

i create a chart :

Set cmdObject = Form2.Controls.Add("MSChart20Lib.MSChart", "achart" + Trim(Str(n)))

thats not a problem
i work with it a bit
now i need this :

1- i wanna be able to prints those charts
2- i need to save those charts in a .doc or .txt

is this possible

for the Print, what i have now, is i create it on an other form, print and then clear evrytime, but i wanna know if there is an other way

i really need help
  • 3
  • 2
1 Solution
Hi Italbro

Try to make this:
on your form Declare

Dim F
Dim Filename

sub commandPrint()
Filename = Index you Chart name
printer.currentX = 1000
Printer.currentY = 3000
printer.print Filename
end sub

Does'nt print colors to do so you need to convert to bitmap or print with Crystal Report.

Sub commandSave()
FileName = Index your Chart name
F = Free file
Open "Chart.dat" for Output as #F
Print #f,Filename
Close #f
end sub

I 'm Not sure if you ned to save it in binary file, depends on your chart.
To Load Chart.dat use:

Sub CommandOpen()
F=Free File
Open "Chart.dat" for input as F
Filename = Input(LOF(F),F)
Close F

Good Luck
Italbro4Author Commented:
i'll try this later
but the CommandSave and COmmandOpen

i'm not to sure i understand

I just need to create a new .doc and save the chart there
so i open the file, save in it
and close it
why u doing 2 step for it
Italbro4Author Commented:

it dosent really work

FileName = Index your Chart name // gives me an error

it creates the file
i need a .doc

u think u can make it work
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Italbro4Author Commented:
can i get my points back, cause i didnt get any good answer
Leave a question for 0 points at Community Support link for deletion of question
Hi Italbro4
Sorry By the delay of your problem, but sometimes i do not enought time to resolve ans understand some problems. But i Never Quick before say something.
put a picture box on a form, name it as Picture1
4 CommonButtons
Command1 will be to draw your Graph
Command 2 Will Print your Graph, You'll Have control on Paper position and Graph Size
Command 3 Will put your Graph as Bitmap in memory to use it on any Design Program or photo Program as PaintShop Etc.
Command4 Will save your graph on your project Directiry as a Bitmap.

Dim x, y, N
Dim A, B

Private Sub Command2_Click()
x = 1000    'Printer Position
y = 1000
A = 750     'Size Graphic
B = 750
Printer.PaintPicture Picture1.Image, x, y, A, B
End Sub

Private Sub Command1_Click()
   x = Picture1.ScaleWidth / 2
   y = Picture1.ScaleHeight / 2
   For N = 1 To 10
      Picture1.Circle (x, y), N * 50, RGB(N * 8, N * 15, N * 12)
   Next N
End Sub

Private Sub Command3_Click()
   Clipboard.SetData Picture1.Image, vbCFBitmap
End Sub

Private Sub Command4_Click()
   SavePicture Picture1.Image, App.Path & "\TEST.BMP"
End Sub

I Hope this is what you want.

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now