A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Output to excel == replace worksheet



 
 
Thread Tools Display Modes
  #1  
Old December 24th, 2007, 12:13 PM posted to microsoft.public.access.forms
shiro[_2_]
external usenet poster
 
Posts: 41
Default Output to excel == replace worksheet

Usually out to excel will replace a workbook.Can we make it
to replace worksheet only.Thank's


  #2  
Old December 24th, 2007, 03:54 PM posted to microsoft.public.access.forms
Arvin Meyer [MVP]
external usenet poster
 
Posts: 4,231
Default Output to excel == replace worksheet

"shiro" wrote in message
...
Usually out to excel will replace a workbook.Can we make it
to replace worksheet only.Thank's


How about, just replacing the contents of a cell, or cells?

Dim appXL As Object
Dim wkb As Object
Dim wks As Object

Set appXL = CreateObject("Excel.Application")
Set wkb = appXL.Workbooks.Open("C:\MyFolder\MyWorkBook.xls")
Set wks = wkb.Worksheets(1)

wks.Cells(1, 1) = "Hello World"
wks.Cells(1, 2) = "Good-bye now"
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


  #3  
Old December 25th, 2007, 02:50 AM posted to microsoft.public.access.forms
shiro[_2_]
external usenet poster
 
Posts: 41
Default Output to excel == replace worksheet

I'm sorry Mr Arvin,
I haven't test your code,but I want to ask more question.
If I outputting a continuous form,and if there are some records
in it,does this code will insert all records of a field into one cell?
And then,how to cahnge the value of the cell with the value of my
query's fields or my form's fields.
Thank's for help




"Arvin Meyer [MVP]" wrote in message
...
"shiro" wrote in message
...
Usually out to excel will replace a workbook.Can we make it
to replace worksheet only.Thank's


How about, just replacing the contents of a cell, or cells?

Dim appXL As Object
Dim wkb As Object
Dim wks As Object

Set appXL = CreateObject("Excel.Application")
Set wkb = appXL.Workbooks.Open("C:\MyFolder\MyWorkBook.xls")
Set wks = wkb.Worksheets(1)

wks.Cells(1, 1) = "Hello World"
wks.Cells(1, 2) = "Good-bye now"
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com






  #4  
Old December 25th, 2007, 12:31 PM posted to microsoft.public.access.forms
Arvin Meyer [MVP]
external usenet poster
 
Posts: 4,231
Default Output to excel == replace worksheet

Instead of inserting values cell by cell, you can use Excel ranges to insert
records row by row. Here's some code that will do that:

http://www.mvps.org/access/modules/mdl0035.htm
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

"shiro" wrote in message
...
I'm sorry Mr Arvin,
I haven't test your code,but I want to ask more question.
If I outputting a continuous form,and if there are some records
in it,does this code will insert all records of a field into one cell?
And then,how to cahnge the value of the cell with the value of my
query's fields or my form's fields.
Thank's for help




"Arvin Meyer [MVP]" wrote in message
...
"shiro" wrote in message
...
Usually out to excel will replace a workbook.Can we make it
to replace worksheet only.Thank's


How about, just replacing the contents of a cell, or cells?

Dim appXL As Object
Dim wkb As Object
Dim wks As Object

Set appXL = CreateObject("Excel.Application")
Set wkb = appXL.Workbooks.Open("C:\MyFolder\MyWorkBook.xls")
Set wks = wkb.Worksheets(1)

wks.Cells(1, 1) = "Hello World"
wks.Cells(1, 2) = "Good-bye now"
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com








  #5  
Old December 30th, 2007, 06:41 AM posted to microsoft.public.access.forms
shiro[_2_]
external usenet poster
 
Posts: 41
Default Output to excel == replace worksheet

I've read the code written by Mr Dev on thesite but that is not excatly what
I
want.Here is my condition:
Some data that I want to output to are on the form Header,and the others
are on the detail section of my continuous form.Below is where I've got so
far

Dim appXL As Object
Dim wkb As Object
Dim wks As Object

Set appXL = CreateObject("Excel.Application")
Set wkb = appXL.Workbooks.Open("C:\MyFolder\My Workbook.xls")
Set wks = wkb.Worksheets(1)
appXL.Visible = True

wks.Cells(4, 3) = [Customer]
wks.Cells(6, 3) = [LotNo]
wks.Cells(7, 3) = [Model]

Field 'Customer' and 'LotNo' are on the form header and 'Model' is on
the detail form.And I always limitting the number of record returned to
5 record only that mean excel cell (7, 3) until cell (11, 3) should contains
the 5 values of the 'Model'.How to do that.?




"Arvin Meyer [MVP]" wrote in message
...
Instead of inserting values cell by cell, you can use Excel ranges to

insert
records row by row. Here's some code that will do that:

http://www.mvps.org/access/modules/mdl0035.htm
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

"shiro" wrote in message
...
I'm sorry Mr Arvin,
I haven't test your code,but I want to ask more question.
If I outputting a continuous form,and if there are some records
in it,does this code will insert all records of a field into one cell?
And then,how to cahnge the value of the cell with the value of my
query's fields or my form's fields.
Thank's for help




"Arvin Meyer [MVP]" wrote in message
...
"shiro" wrote in message
...
Usually out to excel will replace a workbook.Can we make it
to replace worksheet only.Thank's

How about, just replacing the contents of a cell, or cells?

Dim appXL As Object
Dim wkb As Object
Dim wks As Object

Set appXL = CreateObject("Excel.Application")
Set wkb = appXL.Workbooks.Open("C:\MyFolder\MyWorkBook.xls")
Set wks = wkb.Worksheets(1)

wks.Cells(1, 1) = "Hello World"
wks.Cells(1, 2) = "Good-bye now"
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com










  #6  
Old December 31st, 2007, 03:51 AM posted to microsoft.public.access.forms
Arvin Meyer [MVP]
external usenet poster
 
Posts: 4,231
Default Output to excel == replace worksheet

"shiro" wrote in message
...

Field 'Customer' and 'LotNo' are on the form header and 'Model' is on
the detail form.And I always limitting the number of record returned to
5 record only that mean excel cell (7, 3) until cell (11, 3) should
contains
the 5 values of the 'Model'.How to do that.?


You must build a recordset or a query and either export the query with the
TransferSpreadsheet function (look it up in help)

Or loop through a recordset, writing the data to the Excel sheet one cell at
a time.
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


 




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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:59 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.