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_Cl ick()
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.Applic ation")
Set wb = xl.Workbooks.Add
Set exportsheet = wb.Worksheets(1)
exportsheet.Name = "Chemical Search"
xl.Application.Visible = True
Set rs = db.OpenRecordset(Me.Record Source)
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.LineStyl e = xlContinuous
exportsheet.Cells.EntireCo lumn.AutoF it
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
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_Cl
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.Applic
Set wb = xl.Workbooks.Add
Set exportsheet = wb.Worksheets(1)
exportsheet.Name = "Chemical Search"
xl.Application.Visible = True
Set rs = db.OpenRecordset(Me.Record
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")
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.LineStyl
exportsheet.Cells.EntireCo
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
ASKER