Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

VB6 and Creating and Excel spreadsheet

Posted on 2005-04-15
1
Medium Priority
?
247 Views
Last Modified: 2010-05-02
Hi Everyone,
i'm trying to create an excel spreadsheet which only has 1 sheet (the normal default is 3 sheets).  I have tried to remove the extra two sheets, but Excel generates a warning when you try to delete the sheet, and I don't want my customer to have to worry about the warning.  I'm going to be adding sheets (which I can do without problems), sheet 1 will be a title page, then I will be adding 1 new sheet for each item in a database, and I don't want those extra two sheets in the workbook.  Does anyone have any ideas about this?  Thanks in advance for your help.
0
Comment
Question by:TopCatOnyx
1 Comment
 
LVL 35

Accepted Solution

by:
mvidas earned 2000 total points
ID: 13792448
Hi TCO,

There are a couple of ways you can accomplish this.
For all of this, it assumes xl is your application variable
Set xl = Excel.Application

If you use
 xl.Workbooks.Add 1
or
 xl.Workbooks.Add -4167
These will create a standard workbook with only 1 sheet in it.

You can remove the warning of deleting the sheets using xl.DisplayAlerts = False / True, like:
 xl.Workbooks.Add
 xl.DisplayAlerts = False
 For i = xl.SheetsInNewWorkbook To i Step -1
  xlWB.Sheets(i).Delete
 Next i
 xl.DisplayAlerts = True

(the xl.SheetsInNewWorkbook property should be used instead of 3, not all users use 3)

Any questions, let me know!
Matt
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question