Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2008

Tip: Looking for answers? Try searching our database.

Excel 2003 vbs script problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ralf Meuser - 20 Mar 2008 11:08 GMT
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.ActiveWorkBook.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
Mark Ivey - 20 Mar 2008 12:40 GMT
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

> Hi there
>
[quoted text clipped - 32 lines]
>
> Ralf
Dave Peterson - 20 Mar 2008 12:54 GMT
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.

> Hi there
>
[quoted text clipped - 32 lines]
>
> Ralf

Signature

Dave Peterson

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.