Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Excel 2003 vbs script problem

Hi there

I'm trying to create a script which adds a new sheet with datas from other
sheets.
Some things work now but I have still an error and I realldy don't
understand why.

My script looks like this:
Set objXL = WScript.CreateObject ("Excel.Application")
....
Set objDanach =
objXL.ActiveWorkBook.WorkSheets(objXL.ActiveWorkBo ok.Worksheets.Count)
Set objWb7 = objXL.ActiveWorkBook.WorkSheets.Add(,objDanach)
objWb7.Name = "KPI4-6"
objWb7.Tab.ColorIndex = 7
....
objWb7.Cells(6, 1).Value ="some text..."
objWb7.Cells(6, 1).Font.Italic = TRUE
objWb7.Cells(6, 1).Font.Size = 8
objWb7.Cells(6, 1).Font.ColorIndex = 6
objWb7.Cells(6, 1).Interior.ColorIndex = 34
....
objWb7.Columns("A:A").Select
objWb7.Selection.Columns.AutoFit
objWb7.Range("A1").Select
....


In the last part I get an error on objWb7.Columns("A:A").Select Error Code
800A03EC
the error syas someing like Select class Rang failed



Thanks in advance for any help

Best regards

Ralf



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default Excel 2003 vbs script problem

Instead of actually using a SELECTION, try this:

objWb7.Columns("A:A").EntireColumn.AutoFit

And I would not worry about the A1 Selection unless it is entirely
necessary.

Mark

"Ralf Meuser" wrote in message
...
Hi there

I'm trying to create a script which adds a new sheet with datas from other
sheets.
Some things work now but I have still an error and I realldy don't
understand why.

My script looks like this:
Set objXL = WScript.CreateObject ("Excel.Application")
...
Set objDanach =
objXL.ActiveWorkBook.WorkSheets(objXL.ActiveWorkBo ok.Worksheets.Count)
Set objWb7 = objXL.ActiveWorkBook.WorkSheets.Add(,objDanach)
objWb7.Name = "KPI4-6"
objWb7.Tab.ColorIndex = 7
...
objWb7.Cells(6, 1).Value ="some text..."
objWb7.Cells(6, 1).Font.Italic = TRUE
objWb7.Cells(6, 1).Font.Size = 8
objWb7.Cells(6, 1).Font.ColorIndex = 6
objWb7.Cells(6, 1).Interior.ColorIndex = 34
...
objWb7.Columns("A:A").Select
objWb7.Selection.Columns.AutoFit
objWb7.Range("A1").Select
...


In the last part I get an error on objWb7.Columns("A:A").Select Error
Code 800A03EC
the error syas someing like Select class Rang failed



Thanks in advance for any help

Best regards

Ralf



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Excel 2003 vbs script problem

You can only select a range on the selected/active worksheet.

Try adding:
objWb7.Select
objWb7.Columns("A:A").Select

But you don't need to select a range to work with it:

objWb7.Columns("A:A").Autofit
should work.

But
objWb7.Range("A1").Select
would fail. But you may not need this line if you're not selecting stuff.

Ralf Meuser wrote:

Hi there

I'm trying to create a script which adds a new sheet with datas from other
sheets.
Some things work now but I have still an error and I realldy don't
understand why.

My script looks like this:
Set objXL = WScript.CreateObject ("Excel.Application")
...
Set objDanach =
objXL.ActiveWorkBook.WorkSheets(objXL.ActiveWorkBo ok.Worksheets.Count)
Set objWb7 = objXL.ActiveWorkBook.WorkSheets.Add(,objDanach)
objWb7.Name = "KPI4-6"
objWb7.Tab.ColorIndex = 7
...
objWb7.Cells(6, 1).Value ="some text..."
objWb7.Cells(6, 1).Font.Italic = TRUE
objWb7.Cells(6, 1).Font.Size = 8
objWb7.Cells(6, 1).Font.ColorIndex = 6
objWb7.Cells(6, 1).Interior.ColorIndex = 34
...
objWb7.Columns("A:A").Select
objWb7.Selection.Columns.AutoFit
objWb7.Range("A1").Select
...

In the last part I get an error on objWb7.Columns("A:A").Select Error Code
800A03EC
the error syas someing like Select class Rang failed

Thanks in advance for any help

Best regards

Ralf


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
SaveAs problem in Excel VBA script joannele71 Excel Programming 3 February 22nd 08 09:44 PM
Trying to convert a excel 2003 to 2007, but it contain script. Feejo Excel Discussion (Misc queries) 3 January 2nd 08 01:19 PM
Trying to convert a excel 2003 to 2007, but it contain script. Feejo New Users to Excel 2 December 31st 07 07:08 PM
Excel 2003 VBA Help me complete this Search script RompStar Excel Programming 2 December 14th 07 05:24 PM
Problem with Excel VBA script, decimal bug Richard RE Excel Programming 1 June 22nd 06 09:52 AM


All times are GMT +1. The time now is 05:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"