#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    8
    Rep Power
    0

    Using variables to set columns in vb6


    I am using vb6 on a w7 pc.

    I am trying to use variables to locate columns for formatting.
    What I would like to do is something like this:

    XLWB.worksheets(sheetname).columns(var1:var2).columnwidth=8.5

    var1 and var2 are integers.

    I have been converting these integers to letters using a ConvertToLetter function which I found elsewhere.
    This function converts the value of the variable to a letter eg if var1=3 then
    str1=ConvertToLetter(var1) returns C to str1


    What I am unable to do is then put this into the assignment above.

    Can anyone help please or suggest another way to do it?
  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,449
    Rep Power
    4539
    Even though I don't use Excel, I'd recommend using VBA from within excel.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    8
    Rep Power
    0
    Agree it would be easier but in this case, I am trying to end up with a standalone exe that can be run outside excel.
  6. #4
  7. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,449
    Rep Power
    4539
    I once long ago coded some vb6 code to do some excel work. Excel needs to be installed on any computer that runs the code, then you can research how to instantiate an instance of excel from vb6, then you can use the excel object model to manipulate spreadsheets and issue excel commands.

    I don't know how well or if you can do this with vb6 on windows 7, much has changed in windows. I believe my coding was done back on windows 2000 but it's been so long ago I don't really remember.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester

IMN logo majestic logo threadwatch logo seochat tools logo