![]() |
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/ |
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/ |
All times are GMT +1. The time now is 11:36 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com