![]() |
copy excel to word
Hi, everybody:
I never did this before and I need your expertise. I would like to create a macro button in excel such that whenever I click this button, 3 columns (A, B, and C) with unknown rows under excel sheet1 will be copied and pasted as Unformatted Text into an automatically created word document. Three requirements: 1) The automatically created word document will have a left and right margin of 0.6"; 2) Any rows with something in column A in Excel will be shown as Bold Text in the word documet after copy and copy; 3) The first line of the word document will be center aligned. Anything else will be justified. I appreciate any of your help. You all have a nice 4th of July. Jorge |
copy excel to word
|
copy excel to word
This site should get you started.
http://www.exceltip.com/st/Copy_work...Excel/481.html " wrote: Hi, everybody: I never did this before and I need your expertise. I would like to create a macro button in excel such that whenever I click this button, 3 columns (A, B, and C) with unknown rows under excel sheet1 will be copied and pasted as Unformatted Text into an automatically created word document. Three requirements: 1) The automatically created word document will have a left and right margin of 0.6"; 2) Any rows with something in column A in Excel will be shown as Bold Text in the word documet after copy and copy; 3) The first line of the word document will be center aligned. Anything else will be justified. I appreciate any of your help. You all have a nice 4th of July. Jorge |
copy excel to word
Hi, John and JL:
I tried what you said but still no luck. Any other ideas? Thanks, Jorge |
copy excel to word
Hi, Jorge:
Interesting. Someboy (not me) will help you out! Thanks, |
copy excel to word
Hi, Jorge:
Since I did not see many MVP level expertises showing up today, I did a search and find something from our previous post + my own pratice. Due to my shortage of knowledge, the following code is only for your reference (copy 3 columns from excel and paste special as unformatted text into word) as it doesn't solve your problem. You will need to make a word template with left and right margins of 0.6" and save it under C:\ drive. You will also need to make a bookmark to specify where you want to paste in this word template. I really wish many people will get into this as this is really common in reality. Correct me if I did anything wrong. Thanks, Sub Test() Const wdGoToBookmark = -1 Const wdSaveChanges = -1 Dim ws As Worksheet Dim i As Integer Dim WdApp As Object Dim strFile As String Dim doc As Object 'I assume column C has the most rows among A, B, and C Set Rng = Sheets("Sheet1").Range(Cells(1, "A"), Cells(Rows.Count, "C").End(xlUp)) Rng.Select Selection.Copy strFile = "C:\CopyExcelToWord.doc" On Error Resume Next Set WdApp = GetObject(, "Word.Application") If Err.Number < 0 Then Err.Clear Set WdApp = CreateObject("Word.Application") End If WdApp.Documents.Open Filename:=strFile, ConfirmConversions:=False, ReadOnly:=False Set doc = WdApp.activedocument WdApp.Visible = True With WdApp .Selection.GoTo What:=wdGoToBookmark, Name:="bkmk" .Selection.PasteSpecial Link:=False, DataType:=wdPasteText, Placement:=wdInLine, DisplayAsIcon:=False End With Set WdApp = Nothing End Sub |
copy excel to word
What happend when you recorded yourself doing it? What shoed up in the
macro? John wrote: Hi, John and JL: I tried what you said but still no luck. Any other ideas? Thanks, Jorge |
copy excel to word
Hi, George:
I just had a chance to be online. Thanks for all the work you did. I will try what you wrote here. Thanks again! Jorge |
copy excel to word
Hi, George:
I tried but not sure what's the meaning of Const wdGoToBookmark = -1 and Set WdApp = Nothing Also, how to make a bookmark? Thanks, Jorge |
All times are GMT +1. The time now is 03:03 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com