Results 1 to 2 of 2
  1. #1
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    716
    Thanks
    10
    Thanked 34 Times in 28 Posts

    Open Excel from Word (Office 2003 SP2)

    OK, I give up...

    I know there are lots of topics about this, but none that I've found quite addresses my issue. I would like to create a new worksheet based on a template (.xlt) from a Word macro. I don't have to pass any data to Excel.

    I've tried ShellExecute, but the best I can do is open the template:
    <pre>ShellExecute 0, "Open", strXLT, vbNullString, strPathXLT, 3</pre>

    I've tried creating an Excel.Application object, but I can't see it.
    <pre>Dim oApp As Excel.Application
    Set oApp = CreateObject("Excel.Application")
    oApp.Workbooks.Add Template:=strFolder & strDocument</pre>

    The macro stops unceremoniously after the last line. I've double-checked the path and it's correct. I've tried oApp.Visible, and that opens a new blank workbook. I'm out of ideas for searching and any help will be greatly appreciated. My hair is growing thin. <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23>

    Thanks!
    Kim

  2. #2
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    716
    Thanks
    10
    Thanked 34 Times in 28 Posts

    Re: Open Excel from Word (Office 2003 SP2)

    All right, I didn't give up.

    In the bright light of morning, I was able to rethink and reorder my code. Plus I rebooted, which removed any instances of invisible Excel...

    This is the code that works:
    <pre>Dim oApp as Excel.Application
    Set oApp = CreateObject("Excel.Application")
    With oApp
    .Visible = True
    .Wordbooks.Add Template:=strFolder & strDocument
    End With</pre>

    I also think the code didn't stop... it was just thinking. And since I already had Excel running, it may have been thinking too hard. I've now added code to check for that before creating the Excel object.

    Thanks,
    Kim

Posting Permissions

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