Advertisement
stevennathaniel

Memilih Sheet Excel Menggunakan Nama Sheet

Feb 2nd, 2016
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.87 KB | None | 0 0
  1. Imports Excel = Microsoft.Office.Interop.Excel
  2.  
  3. Imports Microsoft.Office
  4.  
  5.  
  6.  
  7. Public Class Form14
  8.  
  9.     Dim appXL As Excel.Application = Nothing
  10.  
  11.     Dim wbXL As Excel.Workbook = Nothing
  12.  
  13.     Dim shXL As Excel.Worksheet = Nothing
  14.  
  15.     Dim raXL As Excel.Range = Nothing
  16.  
  17.  
  18.  
  19.  
  20.     Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
  21.  
  22.         appXL = New Excel.Application
  23.  
  24.         wbXL = appXL.Workbooks.Open("D:\fileExcel\Latihan100.xlsx")
  25.  
  26.         appXL.Visible = True
  27.  
  28.  
  29.         shXL = wbXL.Sheets("Kertas Baru")
  30.  
  31.         shXL.Activate()
  32.  
  33.  
  34.  
  35.         appXL.UserControl = True
  36.  
  37.         raXL = Nothing
  38.  
  39.         wbXL = Nothing
  40.  
  41.         shXL = Nothing
  42.  
  43.         appXL = Nothing
  44.  
  45.  
  46.         Exit Sub
  47.  
  48. Err_Handler:
  49.  
  50.         MsgBox(Err.Description, vbCritical, "Error " & Err.Number)
  51.  
  52.  
  53.     End Sub
  54. End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement