By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,084 Members | 1,956 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,084 IT Pros & Developers. It's quick & easy.

howto send data from vb to excel for printing

P: 5
Hi
I want to send data from vb (msflexgrid) to excel . buto I dont know how .
can anyne help me?
Apr 9 '07 #1
Share this Question
Share on Google+
3 Replies


Expert 5K+
P: 8,434
Hi
I want to send data from vb (msflexgrid) to excel . buto I dont know how .
can anyne help me?
One way is to add the Microsoft Excel Object Library to the list of References in your project. Look up the documentation on the Excel object - it's quite easy to drive Excel from your VB code.
Apr 9 '07 #2

P: 8
After you added the Microsoft Excel Object Library to the list of References in your project try write this code:
Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim xlApp As New Excel.Application
  3. Dim xlwk As New Excel.Workbook
  4.  xlApp.Interactive = True
  5.  
  6.  Set xlwk = xlApp.Workbooks.Open(App.Path & "\test.xls")  '(test.xls) file already exist in the application folder
  7.  
  8.  xlApp.Cells(1, 1) = 1982    'send the value or object or string  to excel
  9.  
  10.  xlApp.Columns.AutoFit
  11.  xlApp.Visible = True
  12.  ' xlwk.Save
  13.  ' xlApp.Quit
  14.  
Apr 9 '07 #3

Expert 5K+
P: 8,434
After you added the Microsoft Excel Object Library to the list of References in your project try write this code:
...
Thanks deco. I'm afraid I was being a bit lazy.
Apr 9 '07 #4

Post your reply

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