Results 1 to 4 of 4

Thread: Excel Templates. Should be Easy.

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 2000
    Posts
    39

    Red face

    Anyone know where I mght find some code which shows me how to open up an excel template (xlt) in code, write values into a specific worksheet and then save it as an xls file?

  2. #2
    Addicted Member
    Join Date
    Aug 2000
    Posts
    178
    Try the macro recorder......

    Steve

  3. #3
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    ' I don't have a lot of experience in excel but I've
    ' handled littel jobbies like this
    ' I create a macro to do my excel work for me
    ' I then would call the file holding the macro
    '
    ' of course if you need to enter information gathered
    ' on the fly throught your app and write it in this
    ' macro business is not what your are after
    '
    ' then I would run this from my VB Application
    '
    'create and object (Excel SpreadSheet)
          Dim oXL As Object
          Set oXL = CreateObject("Excel.Application")
          
    ' Open the workbook that contains the macro to run.
          oXL.Workbooks.open "C:\Folder\MyFile.xls"
    '
    'as object opens invisible, make visible if needed, if not omit
    'the line oXL.visible=true
    '
          oXL.Visible = True
    '
    ' Run the macro.
          oXL.Application.Run "MyFileName.xls!MyMacroName"
    '
    ' Quit Microsoft Excel.
          oXL.Quit
    '
    ' Free the object from memory.
          Set oXL = Nothing
    '
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  4. #4
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    One problem with using a macro imbedded within Excel is that it gives the standard, pain-in-the-butt, dialog box about Virii. If you're using Excel in hidden mode or if you're opening and closing a lot of workbooks, it becomes a nuisance real fast. The best thing to do, in this instance is move the macro into your VB code, making sure you set the appropriate objects when you modify the macro to make it work with VB.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width