468,134 Members | 1,265 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,134 developers. It's quick & easy.

opening a new excel sheet using VB

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
Apr 28 '07 #1
1 3163
sahand
2
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,
Apr 30 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Jawahar Rajan | last post: by
5 posts views Thread by Rajiv | last post: by
14 posts views Thread by pmud | last post: by
8 posts views Thread by Djim | last post: by
18 posts views Thread by Frank M. Walter | last post: by
3 posts views Thread by pleaseexplaintome_2 | last post: by
13 posts views Thread by chuckie_9497 | last post: by
27 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.