Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Transfer Excel data to Word

I have a Excel document with some analysis data, but I want to print
the data in a Word document. Now I succeeded in writing a Excel macro
that copies the data into a new Word document (created from Excel).
However I have two problems.

1. The selection.paste does not work anymore in Office 2000. No
error, but also no selection is pasted in word.

In Excel:

dim worddoc as object
Application.ActivateMicrosoftApp xlMicrosoftWord
Set Worddoc = CreateObject("Word.Application")
Worddoc.Documents.Add


Range(Cells(1, 1), Cells(iEndRow, 5)).Select
Selection.Copy

Application.ActivateMicrosoftApp xlMicrosoftWord

Worddoc.Selection.Paste (no data is pasted)


2. why is excel vba differrent from word vba ? I recorded a macro in
word and tried to use these commants in Excel to make the word
document.


EXCEL :
With Worddoc.ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = xlPortrait [does not recognise xlLandscape]
.TopMargin = 10
.BottomMargin = 10
.LeftMargin = 10
.RightMargin = 10
End With

WORD: (from word macro gives errors in Excel
With ActiveDocument.PageSetup (in word macro)
With worddoc.ActiveDocument.PageSetup (in excel macro)
.LineNumbering.Active = False
.Orientation = wdOrientLandscape (error)
.TopMargin = CentimetersToPoints(2.17) (error)
.BottomMargin = CentimetersToPoints(2.17)
.LeftMargin = CentimetersToPoints(2.54)
.RightMargin = CentimetersToPoints(1.54)
.Gutter = CentimetersToPoints(0)
.HeaderDistance = CentimetersToPoints(1.25)
.FooterDistance = CentimetersToPoints(1.25)
.PageWidth = CentimetersToPoints(29.7)
.PageHeight = CentimetersToPoints(21)
.FirstPageTray = wdPrinterDefaultBin (error)
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.GutterPos = wdGutterPosLeft
End With



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Transfer Excel data to Word

test this in the MS Excel:

Dim a As Object
Set a = Nothing
Set a = CreateObject("Word.Application")
a.documents.Add
a.Selection.TypeText ("sample text")
a.Visible = True

Cleber

"Davwe" escreveu na mensagem
...
I have a Excel document with some analysis data, but I want to print
the data in a Word document. Now I succeeded in writing a Excel macro
that copies the data into a new Word document (created from Excel).
However I have two problems.

1. The selection.paste does not work anymore in Office 2000. No
error, but also no selection is pasted in word.

In Excel:

dim worddoc as object
Application.ActivateMicrosoftApp xlMicrosoftWord
Set Worddoc = CreateObject("Word.Application")
Worddoc.Documents.Add


Range(Cells(1, 1), Cells(iEndRow, 5)).Select
Selection.Copy

Application.ActivateMicrosoftApp xlMicrosoftWord

Worddoc.Selection.Paste (no data is pasted)


2. why is excel vba differrent from word vba ? I recorded a macro in
word and tried to use these commants in Excel to make the word
document.


EXCEL :
With Worddoc.ActiveDocument.PageSetup
LineNumbering.Active = False
Orientation = xlPortrait [does not recognise xlLandscape]
TopMargin = 10
BottomMargin = 10
LeftMargin = 10
RightMargin = 10
End With

WORD: (from word macro gives errors in Excel
With ActiveDocument.PageSetup (in word macro)
With worddoc.ActiveDocument.PageSetup (in excel macro)
LineNumbering.Active = False
Orientation = wdOrientLandscape (error)
TopMargin = CentimetersToPoints(2.17) (error)
BottomMargin = CentimetersToPoints(2.17)
LeftMargin = CentimetersToPoints(2.54)
RightMargin = CentimetersToPoints(1.54)
Gutter = CentimetersToPoints(0)
HeaderDistance = CentimetersToPoints(1.25)
FooterDistance = CentimetersToPoints(1.25)
PageWidth = CentimetersToPoints(29.7)
PageHeight = CentimetersToPoints(21)
FirstPageTray = wdPrinterDefaultBin (error)
OtherPagesTray = wdPrinterDefaultBin
SectionStart = wdSectionNewPage
OddAndEvenPagesHeaderFooter = False
DifferentFirstPageHeaderFooter = False
VerticalAlignment = wdAlignVerticalTop
SuppressEndnotes = False
MirrorMargins = False
TwoPagesOnOne = False
GutterPos = wdGutterPosLeft
End With



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
word to excel data transfer help vandy Excel Discussion (Misc queries) 0 February 18th 10 06:42 PM
how can you transfer data from excel to MS word? How do I creat Multiple Personal Folders Excel Discussion (Misc queries) 1 January 2nd 08 03:38 PM
transfer of data from Excel to MS Word amateur Excel Discussion (Misc queries) 2 February 3rd 05 06:48 PM
Transfer data from EXCEL to WORD Robin Clay[_3_] Excel Programming 4 October 16th 03 07:58 PM
Transfer data from EXCEL to WORD Robin Clay[_3_] Excel Programming 0 October 15th 03 01:54 PM


All times are GMT +1. The time now is 03:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"