Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > VBA / Office Integration > Excel > Creating New Excel from VB


Reply
 
Thread Tools Display Modes
  #1  
Old 12-16-2003, 11:13 AM
jcmahal jcmahal is offline
Newcomer
 
Join Date: Jul 2003
Location: California
Posts: 6
Default Creating New Excel from VB


Is there a method to create a new Excel file (if one doesn't exsist) to be written on. I've have the method of writting to the database but is having trouble find a way to create a new Excel file to write on.
Reply With Quote
  #2  
Old 12-16-2003, 12:11 PM
Mike Rosenblum's Avatar
Mike Rosenblum Mike Rosenblum is offline
Microsoft Excel MVP

Forum Leader
* Guru *
 
Join Date: Jul 2003
Location: New York, NY, USA
Posts: 7,848
Default

From Excel VBA:
Code:
Dim WB as Workbook Set WB = Application.Workbooks.Add()
From VB 6.0:
Code:
Dim xlWB as Excel.Workbook Set xlWB = objExcel.Workbooks.Add()
,
Mike
__________________
My Articles:
| Excel from .NET | Excel RibbonX using VBA | Excel from VB6 | CVErr in .NET | MVP |
Avatar by Lebb
Reply With Quote
  #3  
Old 12-16-2003, 01:28 PM
jcmahal jcmahal is offline
Newcomer
 
Join Date: Jul 2003
Location: California
Posts: 6
Default

thanks for the help, much appreciated
Reply With Quote
  #4  
Old 12-16-2003, 06:16 PM
Shibboleth Shibboleth is offline
Newcomer
 
Join Date: Dec 2003
Posts: 14
Default

Additionally, you might like to use;

Code:
Application.SheetsInNewWorkbook = 1 Workbooks.Add

Which, as you can guess, defines how many sheets are in the new workbook. However, this change is permanent, so you might want to do something like;

Code:
CurrentNumberOfSheets = Application.SheetsInNewWorkbook Application.SheetsInNewWorkbook = 1 Workbooks.Add Application.SheetsInNewWorkbook = CurrentNumberOfSheets

So that you can restore that person's 'default sheets' setting.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a VB application but lots of Excel linking shmail786 Excel 6 11-12-2003 03:17 AM
Creating Charts in Excel using VB Durbz Excel 2 09-23-2003 06:11 PM
Problems Creating Pivot tables in Excel with vb aine Word, PowerPoint, Outlook, and Other Office Products 0 04-15-2003 05:43 AM
QB to VB Conversion - By AIO BillSoo Tutors' Corner 0 08-06-2002 11:37 AM
Creating graphs in Excel from VB u2pb Word, PowerPoint, Outlook, and Other Office Products 30 04-11-2002 08:32 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->