423,850 Members | 1,069 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,850 IT Pros & Developers. It's quick & easy.

Need help with generating an excel document using VB

P: 2
Hi


I'm trying to generate an excel document using visual basic? I can preview the report fine but the users want me to generate the report to mirror an excel sheet and export.

I was browsing the net but can't find anything relevant except for 'DoCmd.OutputTo acOutputReport, "name of report", acFormatRTF, , True
which generates the data in a word document.


If anyone has any ideas I'd appreciate it.


Thanks


Anita
Sep 13 '07 #1
Share this Question
Share on Google+
2 Replies


kadghar
Expert 100+
P: 1,295
Hi


I'm trying to generate an excel document using visual basic? I can preview the report fine but the users want me to generate the report to mirror an excel sheet and export.

I was browsing the net but can't find anything relevant except for 'DoCmd.OutputTo acOutputReport, "name of report", acFormatRTF, , True
which generates the data in a word document.


If anyone has any ideas I'd appreciate it.


Thanks


Anita
create an object with an excel application in it, then add to it anything you want

something like:

Expand|Select|Wrap|Line Numbers
  1. dim obj1 as object
  2. set obj1 = createobject("excel.application")
  3. obj1.visible=true
  4. obj1.workbooks.add
Then you can add to it anything you want:

like

Expand|Select|Wrap|Line Numbers
  1. obj1.cells(1,1).value = "hello world"
or if you have an array with 10 elements, you can do:

Expand|Select|Wrap|Line Numbers
  1. with obj1.workbooks(1).worksheets(1)
  2.     .range(.cells(1,1), .cells(1,10))= myarray
  3. end with
hope that helps
Sep 13 '07 #2

P: 2
It's exactly what I needed and it's worked perfectly.


Thanks very much for the help


Anita
Sep 13 '07 #3

Post your reply

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