----- Original Message -----
From: "Aftab Ahmed"
Subject: [PCSOFT] Automating Excel
> To automate Excel how would you call an Excel defined function eg Histogram (found under tools, data analysis) in
a VBA procedure (with all its parameters)?
> Any help provided would be appreciated
> Aumor
Below is a snippet from the only project I had to do that had anything to do with automating Excel. I don't know if
it will help you, but what this did was open Excel, do a bunch of calculations (distance.xls), then it put the data
into my program and closed Excel - all without ever seeing Excel. hth
Al Thompson
Private Sub cmdConvert_Click()
Set xlapp = CreateObject("excel.application")
Set xlbook = xlapp.Workbooks.Open("C:\Distance.xls")
Set xlsheet = xlbook.Worksheets(1)
xlapp.Visible = False
xlsheet.Cells(1, 3) = Val(txtPreferred.Text)
xlsheet.Cells(6, 2).GoalSeek Goal:=xlsheet.Cells(1, 3), _
changingcell:=xlsheet.Cells(1, 2)
txtFound.Text = Format(xlsheet.Cells(6, 2).Value, "#,###.00")
xlapp.DisplayAlerts = False
xlapp.Quit
End Sub
Curious about the people moderating your
messages? Visit our staff web site:
http://freepctech.com/staff.shtml
|