Ashfaque
Search Beautiful Girls from your town for night
- Local time
- Tomorrow, 00:56
- Joined
- Sep 6, 2004
- Messages
- 897
Hello,
I have managed to activate Excel sheet2 thru my below vba code but sometime it works perfectly and sometime it produces subjected error on Red color line.
Dim objXL As Excel.Application
Dim objWkb As Excel.Workbook
Dim objSht As Excel.Worksheet
Dim objSht2 As Excel.Worksheet
......
........
...........
Set objXL = New Excel.Application
objXL.Visible = True
Set objWkb = objXL.Workbooks.Open("D:\SLS DB\CUSTOMINV.xls")
Set objSht = objWkb.Worksheets("Sheet1")
.........
...........
.............
Set objSht2 = objWkb.Worksheets("Sheet2")
Workbooks("CUSTOMINV.xls").Worksheets("Sheet2").Activate
objSht2.Cells(12, 2).Value = rst!CustomerName
objSht2.Cells(13, 2).Value = rst2!CustAddress
objSht2.Cells(14, 2).Value = rst2!City + ", " + rst2!Country
objSht2.Cells(16, 2).Value = rst2!Tel + " Fax:" + rst2!Fax
objSht2.Cells(15, 6).Value = rst2!PaymentTerms
objXL.ActiveSheet.Name = "D00" + Forms!F_SOHeader!CustomDNNum
....
......
........
Set objSht = Nothing
Set objSht2 = Nothing
Set objWkb = Nothing
Set objXL = Nothing
....
......
When I am closing my form and opening again, it works without any problem.
Can someone let me know where it went wrong?
Regards,
Ashfaque
I have managed to activate Excel sheet2 thru my below vba code but sometime it works perfectly and sometime it produces subjected error on Red color line.
Dim objXL As Excel.Application
Dim objWkb As Excel.Workbook
Dim objSht As Excel.Worksheet
Dim objSht2 As Excel.Worksheet
......
........
...........
Set objXL = New Excel.Application
objXL.Visible = True
Set objWkb = objXL.Workbooks.Open("D:\SLS DB\CUSTOMINV.xls")
Set objSht = objWkb.Worksheets("Sheet1")
.........
...........
.............
Set objSht2 = objWkb.Worksheets("Sheet2")
Workbooks("CUSTOMINV.xls").Worksheets("Sheet2").Activate
objSht2.Cells(12, 2).Value = rst!CustomerName
objSht2.Cells(13, 2).Value = rst2!CustAddress
objSht2.Cells(14, 2).Value = rst2!City + ", " + rst2!Country
objSht2.Cells(16, 2).Value = rst2!Tel + " Fax:" + rst2!Fax
objSht2.Cells(15, 6).Value = rst2!PaymentTerms
objXL.ActiveSheet.Name = "D00" + Forms!F_SOHeader!CustomDNNum
....
......
........
Set objSht = Nothing
Set objSht2 = Nothing
Set objWkb = Nothing
Set objXL = Nothing
....
......
When I am closing my form and opening again, it works without any problem.
Can someone let me know where it went wrong?
Regards,
Ashfaque