PC Review


Reply
Thread Tools Rate Thread

Adding New Workbook

 
 
=?Utf-8?B?QyBIYXllcw==?=
Guest
Posts: n/a
 
      26th Sep 2007
I am trying to manipulate a new worksheet from Access. When running this
code the first time the sheet is created and manipulated with no problem. If
I attempt to rerun the code it fails.

Run-time Error '1004':
Method 'Range' of Object '_Global' failed

any ideas as to my instancing the sheet? maybe the wrong method.


Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set xlWrkbk = xlApp.Workbooks.Add
ii = 1
For i = 1 To 15 Step 2
Range("A" & i) = "Pre " & ii
ii = ii + 1
Next i


 
Reply With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      26th Sep 2007
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set xlWrkbk = xlApp.Workbooks.Add
ii = 1
For i = 1 To 15 Step 2
xlWrkbk.Activesheet.Range("A" & i) = "Pre " & ii
ii = ii + 1
Next i



--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"C Hayes" <(E-Mail Removed)> wrote in message
news:BA4BDBE3-3531-4F5D-9BAE-(E-Mail Removed)...
>I am trying to manipulate a new worksheet from Access. When running this
> code the first time the sheet is created and manipulated with no problem.
> If
> I attempt to rerun the code it fails.
>
> Run-time Error '1004':
> Method 'Range' of Object '_Global' failed
>
> any ideas as to my instancing the sheet? maybe the wrong method.
>
>
> Set xlApp = CreateObject("Excel.Application")
> xlApp.Visible = True
> Set xlWrkbk = xlApp.Workbooks.Add
> ii = 1
> For i = 1 To 15 Step 2
> Range("A" & i) = "Pre " & ii
> ii = ii + 1
> Next i
>
>



 
Reply With Quote
 
=?Utf-8?B?QyBIYXllcw==?=
Guest
Posts: n/a
 
      26th Sep 2007
Thank you

"Bob Phillips" wrote:

> Set xlApp = CreateObject("Excel.Application")
> xlApp.Visible = True
> Set xlWrkbk = xlApp.Workbooks.Add
> ii = 1
> For i = 1 To 15 Step 2
> xlWrkbk.Activesheet.Range("A" & i) = "Pre " & ii
> ii = ii + 1
> Next i
>
>
>
> --
> HTH
>
> Bob
>
> (there's no email, no snail mail, but somewhere should be gmail in my addy)
>
> "C Hayes" <(E-Mail Removed)> wrote in message
> news:BA4BDBE3-3531-4F5D-9BAE-(E-Mail Removed)...
> >I am trying to manipulate a new worksheet from Access. When running this
> > code the first time the sheet is created and manipulated with no problem.
> > If
> > I attempt to rerun the code it fails.
> >
> > Run-time Error '1004':
> > Method 'Range' of Object '_Global' failed
> >
> > any ideas as to my instancing the sheet? maybe the wrong method.
> >
> >
> > Set xlApp = CreateObject("Excel.Application")
> > xlApp.Visible = True
> > Set xlWrkbk = xlApp.Workbooks.Add
> > ii = 1
> > For i = 1 To 15 Step 2
> > Range("A" & i) = "Pre " & ii
> > ii = ii + 1
> > Next i
> >
> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding over 30 worksheets in a workbook -E Microsoft Excel New Users 4 30th Dec 2008 06:11 PM
Adding a chart to large workbook brings workbook activity to a hal Dale Microsoft Excel Misc 6 29th Dec 2008 05:50 PM
Many users adding to one workbook? Ed Microsoft Excel Programming 8 1st May 2007 08:49 PM
Adding sheets to workbook =?Utf-8?B?U3VzYW4=?= Microsoft Excel Worksheet Functions 4 23rd Oct 2006 05:55 PM
Adding CC: to workbook e-mailed? =?Utf-8?B?amVubmlmZXI=?= Microsoft Excel Programming 1 5th Apr 2005 05:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:06 AM.