H
HGood
Hi, I asked this over in the Reports forum, but likely should have asked it
here...
I have code below which others here have kindly helped me to assemble. It
works great in the Form, where one project is in focus at a time. But I'd
like
now to design a Report so it will report on these same 4 ranges from
the spreadsheet, but all in one report. There are about 150 project
spreadsheets each with their unique EthID number as file name, so I'd like
the report to display these 4 ranges on one line per project. So the entire
report would be about 2 or 3 pages long.
I've tried adjusting the code below a bit and inserting it into the
OnActivate
Event of the Report. But I can't figure out how to make it work. It gets
hung up at the Me.ctrlEthID line.
Thanks very much for any help you can offer.
Haroldd
=======================================
Private Sub Form_Load()
Dim xlApp As Object ' Reference to Microsoft Excel.
Dim xlBook As Object 'Workbook Object
Dim xlSheet As Object 'Worksheet Object
Dim varRet As Variant
Set xlApp = CreateObject("excel.application")
Set xlBook = xlApp.Workbooks.Open("W:\Field Coordinators\!Plan &
Progress Spreadsheets\" & Me.ctrlEthID & ".xls.lnk", 0, True)
Me.Qtr = xlBook.Worksheets("Progress").Range("aa18")
Me.Yr = xlBook.Worksheets("Progress").Range("ab18")
'Me.Planned = xlBook.Worksheets("Progress").Range("ao40")
Me.Planned =
xlApp.WorksheetFunction.Sum(xlBook.Worksheets("Progress").Range("AL19:AL39"))
Me.Actual = xlBook.Worksheets("Progress").Range("ao40")
xlBook.Close SaveChanges:=False
xlApp.Quit
Set xlBook = Nothing
Set xlApp = Nothing
End Sub
here...
I have code below which others here have kindly helped me to assemble. It
works great in the Form, where one project is in focus at a time. But I'd
like
now to design a Report so it will report on these same 4 ranges from
the spreadsheet, but all in one report. There are about 150 project
spreadsheets each with their unique EthID number as file name, so I'd like
the report to display these 4 ranges on one line per project. So the entire
report would be about 2 or 3 pages long.
I've tried adjusting the code below a bit and inserting it into the
OnActivate
Event of the Report. But I can't figure out how to make it work. It gets
hung up at the Me.ctrlEthID line.
Thanks very much for any help you can offer.
Haroldd
=======================================
Private Sub Form_Load()
Dim xlApp As Object ' Reference to Microsoft Excel.
Dim xlBook As Object 'Workbook Object
Dim xlSheet As Object 'Worksheet Object
Dim varRet As Variant
Set xlApp = CreateObject("excel.application")
Set xlBook = xlApp.Workbooks.Open("W:\Field Coordinators\!Plan &
Progress Spreadsheets\" & Me.ctrlEthID & ".xls.lnk", 0, True)
Me.Qtr = xlBook.Worksheets("Progress").Range("aa18")
Me.Yr = xlBook.Worksheets("Progress").Range("ab18")
'Me.Planned = xlBook.Worksheets("Progress").Range("ao40")
Me.Planned =
xlApp.WorksheetFunction.Sum(xlBook.Worksheets("Progress").Range("AL19:AL39"))
Me.Actual = xlBook.Worksheets("Progress").Range("ao40")
xlBook.Close SaveChanges:=False
xlApp.Quit
Set xlBook = Nothing
Set xlApp = Nothing
End Sub