Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Jun 2003
    Location
    Minneapolis, Minnesota, USA
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Opening MS Excel using HTML Scripts (VB 6.3 - Excel 2003)

    Hi:
    I'm having problems opening an Excel file outside of the browser. I found the following script that seems to offer a good starting point for what I need, but modification of the script to open a given file either does nothing or fleetingly opens Excel and then closes it again.

    The script:
    <SCRIPT LANGUAGE="VBScript">

    sub button1_onclick()

    ' Launch Excel
    dim app
    set app = createobject("Excel.Application")

    ' Make it visible
    app.Visible = true

    ' Add a new workbook
    dim wb
    set wb = app.workbooks.add

    ' Fill array of values first...
    dim arr(19,9) ' Note: VBScript is zero-based
    for i = 1 to 20
    for j = 1 to 10
    arr(i-1,j-1) = i*j
    next
    next

    ' Declare a range object to hold our data
    dim rng
    set rng = wb.Activesheet.Range("A1").Resize(20,10)

    ' Now assign them all in one shot...
    rng.value = arr

    ' Add a new chart based on the data
    wb.Charts.Add
    wb.ActiveChart.ChartType = 70 'xl3dPieExploded
    wb.ActiveChart.SetSourceData rng, 2 ' xlColumns
    wb.ActiveChart.Location 2, "Sheet1" 'xlLocationAsObject

    ' Rotate it around...
    for i = 1 to 360 step 30
    wb.activechart.rotation = i
    next

    ' Give the user control of Excel
    app.UserControl = true

    end sub
    </SCRIPT>

    I've modifed this by replacing pretty much everything after 'make it visible (except for ' give the user control) with workbooks.open, to no avail.

    Any thoughts?

    CJ

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Opening MS Excel using HTML Scripts (VB 6.3 -

    I think the security model should prevent you from doing this. Is it necessary to automate Excel from the web page? Alternatively, could you launch Excel with a particular XLT file and have code run based on that event?

    Old threads that might be relevant:

    Re: Using Excel Macros under IE4 (IE4, Excel 2000) 06-May-02
    Re: Generate a new doc from a dot on the web (Word 97/SR2) 04-Apr-02
    Re: Open documents and start macros in doc. (IE 6.0.2600.000) 2002

  3. #3
    New Lounger
    Join Date
    Jun 2003
    Location
    Minneapolis, Minnesota, USA
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Opening MS Excel using HTML Scripts (VB 6.3 -

    Is it necessary? Well, from a philosophical point of view, not really. But then, not much is.

    What I'm trying to do is create a "dashboard" of all the tools used in my day-to-day work so that these can be shared with the others in my department. This started as a small project and has gotten a bit out of hand, but then that describes many of our endeavors. [img]/forums/images/smilies/wink.gif[/img]

    I'll review the links you provided and see if they will help. Thanks.

    CJ

Posting Permissions

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