HI Arvin,
Thanks for your help. I followed your suggestion and then I was able to
understand how to do this. The example on the website had a filter for excel
so I used that in my code below after I understood how to do it. It worked
one time, but after that I got the following error. Could you take a look
and let me know what I am doing incorrectly? Thanks again for the help.
Run Time Error '91':
Object variable or with block variable not set
Here is my current code:
Private Sub Command87_Click()
Dim xlobject As Object, xlsheet As Object
Dim strFilter As String
Dim strInputFileName As String
strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)", "*.XLS")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)
Set xlobject = GetObject(strInputFileName)
Set xlsheet = xlobject.Application.activeworkbook.sheet1
With xlsheet
.range("b1").Value = "Presale"
.range("c1").Value = "Postsale"
.range("d1").Value = "Total P&L"
.range("a2").Value = "Consulting Revenue"
.range("b2").Value = PreCR
.range("c2").Value = PostCR
.range("d2").Value = CR
.range("a3").Value = "Customer Education"
.range("b3").Value = PreCE
.range("c3").Value = PostCE
.range("d3").Value = CE
.range("a4").Value = "Total Revenue"
.range("b4").Value = PreTR
.range("c4").Value = PostTR
.range("d4").Value = TR
.Cells(1, 1).Font.Size = 25
End With
Set xlobject = Nothing
End Sub