Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

print an excel chart

Status
Not open for further replies.

ShadowFox333

Programmer
Oct 15, 2002
97
US
I have a bunch of files I need to run charts on using vbscript.
THe code below imports a csv file into a worksheet
and fills the cells with the data I need. What I can't figure out is how to not create a chart (column/bar) and print it.
TIA Bob

Option Explicit
Const vbNormal = 1

DIM objXL, objWb, objR ' Excel object variables
DIM Title, Text, tmp, i, j, file, name
dim rng


file = "00110.csv"
name = "00110"


Function GetPath
' Retrieve the script path
DIM path
path = WScript.ScriptFullName ' Script name
GetPath = Left(path, InstrRev(path, "\"))
End Function



' create an Excel object reference
Set objXL = WScript.CreateObject ("Excel.Application")

objXL.WindowState = vbNormal ' Normal
objXL.Height = 300 ' height
objXL.Width = 400 ' width
objXL.Left = 40 ' X-Position
objXL.Top = 20 ' Y-Position
objXL.Visible = true ' show window


' Load the Excel file from the script's folder
Set objWb = objXl.WorkBooks.Open(GetPath+file)

' Get the loaded worksheet object
Set objWb = objXL.ActiveWorkBook.WorkSheets("00110")
objWb.Activate ' not absolutely necessary (for CSV)

'WScript.Echo "worksheet imported"



 
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Hey Mark,
What I really want to do at this point is to pull up a chart
based on the data I import into the cells in the first row and put some titles in the chart and print it then just quit excel. Where do you get all the (ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True) information for all the different applications like axcel and access etc;
TIA
Bob
 
here is what I do when i need to get the code for something like that.

Start recording a macro. Do all the actions by hand. Stop the macro. If you edit the macro in the VB Editor built into Excel you can see all the code to do what you want.

I hope you find this post helpful. Please let me know if it was.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top