setting object to excel application

G

Greg70

I have Access application that uses VBA to open up an Microsoft Excel spread
sheet and merges data to the spread sheet. I get an error when trying to set
my declared object to the create object excel.application. here is the
kicker, I only get the error when trying to run the application on our Citrix
server, otherwise it works just fine with in the organization. here is the
code, I get the error on this line " Set objExcel =
CreateObject("Excel.Application")"

I know of no other way to do this, any help would be greatly appreciated.

Dim rs As ADODB.Recordset
Dim mySQL As String
Dim objExcel As Object
Dim dtPPBegin As Date, dtPPEnd As Date, dtCurrent As Date
Dim hrsWorked As Single, hrsVac As Single, hrsSick As Single, hrsHol As
Single, hrsComp As Single, hrsOther As Single, hrsNoPay As Single, hrsEquiv
As Single
Dim lngDayOfPP As Long
Dim strComment As String
Dim strCriteria As String

mySQL = "SELECT * FROM tblTimeSheetMaster WHERE TimeSheetMasterID = " &
lngMasterID & ";"
Set rs = New ADODB.Recordset
With rs
.ActiveConnection = CurrentProject.Connection
.CursorLocation = adUseServer
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open mySQL
End With

dtPPBegin = rs!PPBegin
dtPPEnd = rs!PPEnd

Set objExcel = CreateObject("Excel.Application")
With objExcel
.Visible = True
.Workbooks.Open ("C:\Database\Timesheet\payroll.xls")
'.Range("A6") = rs!EmployeeID
.Range("L6") = rs!EmployeeName
.Range("M9") = dtPPBegin
.Range("P9") = dtPPEnd
.Range("G33") = rs!Comments
End With
 
D

Douglas J. Steele

Is Excel present on the Citrix Server?

What if you try

Set objExcel = CreateObject("C:\Database\Timesheet\payroll.xls")
 
G

Greg70

the error now has moved to the next line, "objExcel.visible = true". anywhere
I refer to the object objExcel I get an error, i think because I am referring
to the properties and methods of the Excel.Application object and I dont have
one now.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top