Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. IT & Infrastructure
  4. handling excel worksheets.

handling excel worksheets.

Scheduled Pinned Locked Moved IT & Infrastructure
helpcsharpworkspace
2 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    r_mohd
    wrote on last edited by
    #1

    hi all, i am using an excel file in vb.net as following Dim AppExcl As Excel.Application AppExcl = New Excel.Application If AppExcl Is Nothing Then MsgBox("Invalid Action: Excel Could not be Started!", MsgBoxStyle.Critical, "Sys Error") Environment.ExitCode = 0 Exit Sub End If AppExcl.Workbooks.Open("path\filename.xls) With AppExcl '.Visible = False .Range("N7").Value = VATNO.Trim .Range("E7").Value = Format(xVAT_DtF.Date, "dd/MM/yyyy") .Range("H7").Value = Format(xVAT_DtT.Date, "dd/MM/yyyy") .Range("D9").Value = CoName.Trim .Range("H9").Value = CoStatus.Trim .Range("M9").Value = xCoType.Trim End With With AppExcl Dim xPth As String = xChkxOrxCreateDir() If Len(xPth.Trim) = 0 Then Exit Sub .ActiveWorkbook.SaveAs(xPth & "\Abc3.XLSX", , , , , ,XlSaveAsAccessMode.xlNoChange) .Visible = True .DisplayAlerts = False .Workbooks.Close() .Quit() End With it is working very fine, but when i shutdown my system i found a number of excel files(as many times i use this excel file) opened about which system ask to save or not these files. kindly help me. thanks

    rmshah Developer

    J 1 Reply Last reply
    0
    • R r_mohd

      hi all, i am using an excel file in vb.net as following Dim AppExcl As Excel.Application AppExcl = New Excel.Application If AppExcl Is Nothing Then MsgBox("Invalid Action: Excel Could not be Started!", MsgBoxStyle.Critical, "Sys Error") Environment.ExitCode = 0 Exit Sub End If AppExcl.Workbooks.Open("path\filename.xls) With AppExcl '.Visible = False .Range("N7").Value = VATNO.Trim .Range("E7").Value = Format(xVAT_DtF.Date, "dd/MM/yyyy") .Range("H7").Value = Format(xVAT_DtT.Date, "dd/MM/yyyy") .Range("D9").Value = CoName.Trim .Range("H9").Value = CoStatus.Trim .Range("M9").Value = xCoType.Trim End With With AppExcl Dim xPth As String = xChkxOrxCreateDir() If Len(xPth.Trim) = 0 Then Exit Sub .ActiveWorkbook.SaveAs(xPth & "\Abc3.XLSX", , , , , ,XlSaveAsAccessMode.xlNoChange) .Visible = True .DisplayAlerts = False .Workbooks.Close() .Quit() End With it is working very fine, but when i shutdown my system i found a number of excel files(as many times i use this excel file) opened about which system ask to save or not these files. kindly help me. thanks

      rmshah Developer

      J Offline
      J Offline
      Jimmanuel
      wrote on last edited by
      #2

      Are your COM objects being cleaned up properly? You need to use Marshal.ReleaseComObject to release all of the resources that are allocated when using the Excel interop classes. See this[^] thread for details (code is in C# but same principal applies).

      r_mohd wrote:

      it is working very fine, but

      Thanks, it always makes me chuckle when people say "It works fine but . . .". If there's a but then it isn't working fine, is it? :-D

      :badger:

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups