Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to comp.lang.basic.visual.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VB6 with Excel Objects: Please review my code

That would be one of the primary reasons.

--
Regards,
Tom Ogilvy


"Todd Beaulieu" wrote in message
...
Excellent. Thanks!

I used to work so much with Excel/VBA and I know it's ultra-capable. I'd
like to get more into it again.

Do you use late binding to allow for the different versions? I hate having
to do that.


"Tom Ogilvy" wrote in message
...
From help on the workbooks.Add method:

If this argument is a constant, the new workbook contains a single

sheet
of
the specified type. Can be one of the following XlWBATemplate constants:
xlWBATChart, xlWBATExcel4IntlMacroSheet, xlWBATExcel4MacroSheet, or
xlWBATWorksheet.


then from the immediate window:

? xlWBATWorksheet
-4167


Use the value of the constant since if you use late binding, the

constant
won't be defined.

--
Regards,
Tom Ogilvy



"Todd Beaulieu" wrote in message
...
How the heck did you figure that one out? Where's that magic number

come
from?

I chose a different route. Probably less elegant, but it doesn't touch
settings. After starting a new workbook, I simply delete all

worksheets
after the first one.

"Jim Rech" wrote in message
...
I'm game. See below.
--
Jim Rech
Excel MVP

The default is not visible I believe
xlApp.Visible = False

Doing this changes the user's default, so if you want to go this

route,
get
and restore the user's setting.
xlApp.SheetsInNewWorkbook = 1

Another way is: xlApp.Workbooks.Add -4167, which adds a one sheet

workbook
and you do not have to touch SheetsInNewWorkbook. Then your code

would
add
2 sheets instead of 3:
xlWB.Worksheets.Add , , 2
and rename them in the loop.

Set xlWB = xlApp.Workbooks.Add
For i = 1 To 3
Set xlWS = xlWB.Worksheets.Add(After:=xlWB.Worksheets(i))
xlWS.Name = Str$(i)
Next i

There is no reason to capture/restore this since it does not become

the
user's setting and in fact is always turned off automatically when

code
execution ends.
bAlerts = xlApp.DisplayAlerts
xlApp.DisplayAlerts = False
xlWB.Worksheets("Sheet1").Delete
xlWB.Worksheets(1).Activate










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
What does Show Ink in Excel, Review Tab, comment, do? E. Duke 462 Excel Worksheet Functions 0 August 8th 08 04:31 PM
review changes in workbook Farhad Excel Discussion (Misc queries) 2 June 3rd 07 05:10 AM
i have a fax sent to me for review but i cant open its saying i n loans New Users to Excel 3 August 25th 05 03:10 AM
excel review bar broke Excel Discussion (Misc queries) 2 May 5th 05 04:46 PM
Is there a quick way to see which objects have code attached? Terri[_4_] Excel Programming 2 September 12th 03 05:11 PM


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

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

About Us

"It's about Microsoft Excel"