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. General Programming
  3. Visual Basic
  4. problem of save in excel

problem of save in excel

Scheduled Pinned Locked Moved Visual Basic
helptutorial
4 Posts 3 Posters 0 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.
  • N Offline
    N Offline
    nazimghori
    wrote on last edited by
    #1

    hello i am developing an application where i generate my report in excel and have to save in some folder in c drive i wrote my code like

    Dim xl As New Excel.Application
    xl = CreateObject("Excel.Application")
    Workbooks.Add()
    xl.Visible = True

        xl.Columns("A").columnwidth = 5
        xl.Columns("C").columnwidth = 25
        xl.Columns("B").columnwidth = 25
    

    With xl.Range("A" & ii, "C" & ii)
    .Interior.ColorIndex = 5
    End With

    'please suggest also how to change forecolor of cell from "A" to "C"' i get my data from data base and load it in excel and it is working but now i want to save this file in some folder for that i wrote code like

    If Not IO.Directory.Exists("C:\Backup") Then
    IO.Directory.CreateDirectory("C:\Backup")
    End If
    xl.SaveWorkspace(" C:\Backup ")

    but this code is not working so,please suggest what shall i do to save it in this directory... :) :)

    R D 3 Replies Last reply
    0
    • N nazimghori

      hello i am developing an application where i generate my report in excel and have to save in some folder in c drive i wrote my code like

      Dim xl As New Excel.Application
      xl = CreateObject("Excel.Application")
      Workbooks.Add()
      xl.Visible = True

          xl.Columns("A").columnwidth = 5
          xl.Columns("C").columnwidth = 25
          xl.Columns("B").columnwidth = 25
      

      With xl.Range("A" & ii, "C" & ii)
      .Interior.ColorIndex = 5
      End With

      'please suggest also how to change forecolor of cell from "A" to "C"' i get my data from data base and load it in excel and it is working but now i want to save this file in some folder for that i wrote code like

      If Not IO.Directory.Exists("C:\Backup") Then
      IO.Directory.CreateDirectory("C:\Backup")
      End If
      xl.SaveWorkspace(" C:\Backup ")

      but this code is not working so,please suggest what shall i do to save it in this directory... :) :)

      R Offline
      R Offline
      Ray Cassick
      wrote on last edited by
      #2

      nazimghori wrote:

      but this code is not working

      So what errors are you getting? Any exceptions? Do you have rights to save there? What OS are you running on, and under what type of user account?


      LinkedIn[^] | Blog[^] | Twitter[^]

      1 Reply Last reply
      0
      • N nazimghori

        hello i am developing an application where i generate my report in excel and have to save in some folder in c drive i wrote my code like

        Dim xl As New Excel.Application
        xl = CreateObject("Excel.Application")
        Workbooks.Add()
        xl.Visible = True

            xl.Columns("A").columnwidth = 5
            xl.Columns("C").columnwidth = 25
            xl.Columns("B").columnwidth = 25
        

        With xl.Range("A" & ii, "C" & ii)
        .Interior.ColorIndex = 5
        End With

        'please suggest also how to change forecolor of cell from "A" to "C"' i get my data from data base and load it in excel and it is working but now i want to save this file in some folder for that i wrote code like

        If Not IO.Directory.Exists("C:\Backup") Then
        IO.Directory.CreateDirectory("C:\Backup")
        End If
        xl.SaveWorkspace(" C:\Backup ")

        but this code is not working so,please suggest what shall i do to save it in this directory... :) :)

        R Offline
        R Offline
        Ray Cassick
        wrote on last edited by
        #3

        nazimghori wrote:

        please suggest also how to change forecolor of cell from "A" to "C"'

        Try using: range.interior.color =


        LinkedIn[^] | Blog[^] | Twitter[^]

        1 Reply Last reply
        0
        • N nazimghori

          hello i am developing an application where i generate my report in excel and have to save in some folder in c drive i wrote my code like

          Dim xl As New Excel.Application
          xl = CreateObject("Excel.Application")
          Workbooks.Add()
          xl.Visible = True

              xl.Columns("A").columnwidth = 5
              xl.Columns("C").columnwidth = 25
              xl.Columns("B").columnwidth = 25
          

          With xl.Range("A" & ii, "C" & ii)
          .Interior.ColorIndex = 5
          End With

          'please suggest also how to change forecolor of cell from "A" to "C"' i get my data from data base and load it in excel and it is working but now i want to save this file in some folder for that i wrote code like

          If Not IO.Directory.Exists("C:\Backup") Then
          IO.Directory.CreateDirectory("C:\Backup")
          End If
          xl.SaveWorkspace(" C:\Backup ")

          but this code is not working so,please suggest what shall i do to save it in this directory... :) :)

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Well, the save fails because you haven't provided a file name. You gave it the anme of a folder, but no filename...

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
               2006, 2007, 2008

          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