Connecting Tech Pros Worldwide Forums | Help | Site Map

opening a new excel sheet using VB

Newbie
 
Join Date: Apr 2007
Posts: 1
#1: Apr 28 '07
HII ...
please give me a code to open a new excel sheet using VB so that i can also directly add some contents in the cells of the excel sheet in VB itself ..
i ve use the existing excel sheet code given in this portal.. but its not working out..
so its giving error called at the
Sub Main()
Dim oExcel As Excel.Application
Dim oWB As Excel.Workbook
Dim oWS As Excel.Worksheet

Set oExcel = New Excel.Application 'its giving a error here... like User defined type not defined
oExcel.Visible = True


so please help me as soon as possible.

thanks.

Gow
Newbie
 
Join Date: Apr 2007
Posts: 2
#2: Apr 30 '07

re: opening a new excel sheet using VB


Hi,

The code below maybe help you . In this case you can open Excel Application and write the content you want :

Expand|Select|Wrap|Line Numbers
  1.  
  2.     Dim xlWb As Excel.Workbook
  3.     Dim xlWSh As Excel.Worksheet
  4.  
  5.     Set xlWb = Application.Workbooks.Open(txtPath.text)
  6.     Set xlWSh = xlWb.Worksheets(ActiveSheet.Name)
  7.  
Good Luck,
Reply