Link to home
Start Free TrialLog in
Avatar of Nagender Reddy
Nagender Reddy

asked on

Error with Index, ENVIRON and EXCEL.exe

dear team,
I am using office 2016.
i have developed a database using office 2016.
after deploying my end users (uses office 2013 ) facing issues with application.
1. on opening database . It is popup with  " searching for referenced file EXCEL.exe ".
2. HERE IS THE CODE FOR YOUR REFERENCE.
********************************************************************************************************************************
Option Compare Database
Private Sub cmdchemicalsearchexport_Click()
 Dim saveloc As String, strWorksheetPath As String, xl As Object, wb As Object
    Dim exportsheet As Object, Header As Variant, OIHeader As Variant
    'Dim db As DAO.Database, ExportRecordSet As DAO.Recordset
Dim db As Database
Set db = CurrentDb
Dim rs As Recordset
    saveloc = Environ("USERPROFILE") & "\Desktop\"
    saveloc = strWorksheetPath & "ChemicalSearchReport.xlsx"
    Set xl = CreateObject("Excel.Application")
    Set wb = xl.Workbooks.Add
    Set exportsheet = wb.Worksheets(1)
    exportsheet.Name = "Chemical Search"
    xl.Application.Visible = True
   Set rs = db.OpenRecordset(Me.RecordSource)
        exportsheet.Cells(1, 1).Value = "Trade Name"
        exportsheet.Cells(2, 1).Value = "Supplier"
        exportsheet.Cells(3, 1).Value = "Category"
        exportsheet.Cells(4, 1).Value = "Physical Appearance"
        exportsheet.Cells(5, 1).Value = "Active Ingredient"
        exportsheet.Cells(6, 1).Value = "Regional Availability"
        exportsheet.Cells(7, 1).Value = "EPA#"
        exportsheet.Cells(8, 1).Value = "Comment"
        exportsheet.Range("A1:A8").Font.Bold = True
    Dim rownum As Long, colnum As Long
    Dim i As Long
    i = 0
    rownum = 1
    colnum = 2
    rs.MoveFirst
    For Index = 1 To rs.Fields.Count
    If rs.Fields(i).Name <> "SDS" And rs.Fields(i).Name <> "CID" Then
        Do While Not rs.EOF
        exportsheet.Cells(rownum, colnum).Value = rs.Fields(i).Value
        rs.MoveNext
        colnum = colnum + 1
        Loop
        rownum = rownum + 1
        colnum = 2
    End If
    i = i + 1
    rs.MoveFirst
    Next
  With exportsheet
  .Cells(1, i).Select
   Set testRange = .Range(.Cells(1, 1), .Cells(i - 2, i + 1))
 End With
  testRange.Borders.LineStyle = xlContinuous
exportsheet.Cells.EntireColumn.AutoFit
    End Sub
********************************************************************************************************************************
ERROR 1 :
POINTING to Environ(saveloc = Environ("USERPROFILE") & "\Desktop\")
Compile error:
Can't find project or library
ERROR 2:
I HAVE COMMENTED i.e 'saveloc = Environ("USERPROFILE") & "\Desktop\"
pointing to  Index ( for your referecne For Index = 1 To rs.Fields.Count)
Can't find project or library
ASKER CERTIFIED SOLUTION
Avatar of Norie
Norie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Nagender Reddy
Nagender Reddy

ASKER

Working
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Accept: Norie (https:#a42378717)

If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

MacroShadow
Experts-Exchange Cleanup Volunteer