changing the width of cells of excel from vb6.0

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xavierrangel
    New Member
    • Jun 2007
    • 14

    changing the width of cells of excel from vb6.0

    hey there! Would it be possible to change the width of a column in excel from cb6.0. by the click of a button? thanks.
  • tifoso
    New Member
    • Apr 2007
    • 41

    #2
    If u launch the excel from VB6 yes since from inside you'd create an excel object
    and hence you can do anything with Excel, then record a a macro with the stuff you need to happen in Excel, grab that code an embed it into your VB probably with a couple of little tweaks and there u go.


    Ciao

    Comment

    • xavierrangel
      New Member
      • Jun 2007
      • 14

      #3
      could you give me an example. for example this is what i did to write what I want in excel from vb6.0


      Private Sub Command2_Click( )
      Text1 = 1
      Data1.Refresh
      Dim obj1 As Object
      Set obj1 = CreateObject("e xcel.applicatio n")
      obj1.Workbooks. Add
      obj1.Visible = True

      Do Until Text3 = Clear
      obj1.Cells(Text 1, 1).Value = Val(Text2)
      obj1.Cells(Text 1, 2).Value = Text3
      obj1.Cells(Text 1, 3).Value = Text4
      obj1.Cells(Text 1, 4).Value = Text5
      obj1.Cells(Text 1, 5).Value = Text6
      obj1.Cells(Text 1, 6).Value = Text7

      Data1.Recordset .MoveNext
      Text1 = Text1 + 1
      Loop
      End Sub

      as you can see I took all the information from my database and put it into excel but I don't know how to resize the cells once in excel. I've tried this

      ' obj1.Cells.Colu mn(1).ColWidth = 45
      ' obj1.Col(1).Wid th = 45
      or
      ' obj1.Columns(1) .ColWidth = 45
      ' obj1.ActiveShee t.Rows(4).Font = "Times New Roman"

      but it doesn't work. thanks. ah! and do you by any chance know if there's a way to make a program made in vb6.0 compatible with mac? thanks

      Comment

      • kadghar
        Recognized Expert Top Contributor
        • Apr 2007
        • 1302

        #4
        Originally posted by xavierrangel
        could you give me an example. for example this is what i did to write what I want in excel from vb6.0

        (...)

        but it doesn't work. thanks. ah! and do you by any chance know if there's a way to make a program made in vb6.0 compatible with mac? thanks
        Try something like:

        Columns(1).Colu mnWidth = 45

        Good luck!

        Comment

        Working...