Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi, John and JL:
I tried what you said but still no luck. Any other ideas? Thanks, Jorge |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi, Jorge:
Interesting. Someboy (not me) will help you out! Thanks, |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copy Chart from Excel to Word using VBA | Excel Programming | |||
Copy from Word to Excel | Excel Worksheet Functions | |||
Macro to find a word and copy all rows with this word to diff ws | Excel Programming | |||
Copy from Word to Excel, and retain indent, plus word wrap | Excel Discussion (Misc queries) | |||
search for a specific word and copy the word and the preceeding words until a comma | Excel Programming |