From: Angie M. on 11 Feb 2010 00:47 Hello, I received some help a while back but cannot locate my post. I am trying to put my Excel templates on a menu in Word along with my Word templates, hoping that I can create a new spreadsheet based on my Excel template. I have these two macros which I have tried with no luck: Sub Tryit() Dim xlApp As Object Dim xlWB As Object Dim xlWS As Object Dim cRows As Long Dim i As Long Set xlApp = CreateObject("Excel.Application") Set xlWB = xlApp.Workbooks.Add("C:\Program Files\Microsoft Office\Templates\Timetable\Rule16 fed.xlt") 'C:\Program Files\Microsoft Office\templates\Timetable Set xlWS = xlWB.Worksheets(1) End Sub Sub tryitagain() Dim xlWB As Object Dim xlWS As Object Dim cRows As Long Dim i As Long Set xlApp = CreateObject("Excel.Application") Set xlWB = xlApp.Workbooks.Add(Template:="C:\Program Files\Microsoft Office\Templates\Timetable\Rule16 fed.xlt") Set xlWS = xlWB.Worksheets(1) End Sub I'm using Word and Excel 2003. Can anyone help me? Thanks for your time.
From: Peter Jamieson on 18 Feb 2010 11:36 The chances are that your code is creating the Excel workbook but not making the application visible. try putting xlApp.Visible = True at the point where you want the application to become visible (after it has been created!) If you just want to leave it there and do not want to manipulate it further in Word VBA code, you should set the various objects to Nothing at the end of your macro. Peter Jamieson http://tips.pjmsn.me.uk On 11/02/2010 05:47, Angie M. wrote: > Hello, > > I received some help a while back but cannot locate my post. I am trying to > put my Excel templates on a menu in Word along with my Word templates, hoping > that I can create a new spreadsheet based on my Excel template. I have these > two macros which I have tried with no luck: > > Sub Tryit() > > Dim xlApp As Object > Dim xlWB As Object > Dim xlWS As Object > Dim cRows As Long > Dim i As Long > Set xlApp = CreateObject("Excel.Application") > Set xlWB = xlApp.Workbooks.Add("C:\Program Files\Microsoft > Office\Templates\Timetable\Rule16 fed.xlt") > 'C:\Program Files\Microsoft Office\templates\Timetable > Set xlWS = xlWB.Worksheets(1) > > End Sub > > Sub tryitagain() > > Dim xlWB As Object > Dim xlWS As Object > Dim cRows As Long > Dim i As Long > Set xlApp = CreateObject("Excel.Application") > Set xlWB = xlApp.Workbooks.Add(Template:="C:\Program Files\Microsoft > Office\Templates\Timetable\Rule16 fed.xlt") > Set xlWS = xlWB.Worksheets(1) > > End Sub > > I'm using Word and Excel 2003. Can anyone help me? Thanks for your time.
|
Pages: 1 Prev: Why is my Template 'Dirty'? Next: Excel date column for working out time differences |