hi there
I need to display the data from a list of named cells (NameCells) when there is a value for that specific cell.
here is my code
VB Code:
Private Sub PrintTest() Dim xlApp As Object Dim xlWkBk As Object Dim xlSheet As Object Dim filePath As String Dim NameVal As String Dim DescVal As String Dim DeptVal As String Dim Purpose As String ' set values NameVal = "AirCon1" DescVal = " Air Con" DeptVal = "IT" PurposeVal = "" filePath = "c:\Test Excel\Test.xls" Set xlApp = CreateObject("Excel.Application") Set xlWkBk = xlApp.Workbooks.Open(filePath) Set xlSheet = xlWkBk.Worksheets(1) With xlSheet If NameVal <> Null Then '.Range(get from the NamedCell).Value = NameVal End If ' and so on End With xlWkBk.PrintOut xlWkBk.Close SaveChanges:=False xlApp.Quit Set xlSheet = Nothing Set xlWkBk = Nothing Set xlApp = Nothing End Sub Private Sub NamedCell(TemplatePath As String, _ Name As String, _ Desc As String, _ Dept As String, _ Purpose As String) Const NamedCell_Name As String = "Name" Const NamedCell_Desc As String = " Desc" Const NamedCell_Dept As String = " Dept" Const NamedCell_Purpose As String = " Purpose" End Sub




Reply With Quote