![]() |
|
|
|
#1
|
|||
|
|||
|
Hi everyone,
I'm new to VBA and I'm facing an issue with a macro that involves copying text from a Microsoft Word document based on data from an Excel file. I would appreciate your help in resolving this problem. I want the macro to do the following: 1. Browse the specified Excel sheet 2. Find the text according to that specified Excel sheet 3. Copy them accordingly to the clipboard I've attached the Excel file (which is a list of names) here. LIST.xlsx Here's the code I have so far. But it cannot work: Code:
Sub CopyTextToClipboard()
Dim xlApp As Object
Dim xlWB As Object
Dim xlWS As Object
Dim rng As Range
Set xlApp = CreateObject("Excel.Application")
Set xlWB = xlApp.Workbooks.Open("C:\Users\Desktop\List.xlsx")
Set xlWS = xlWB.Worksheets("LIST")
Set rng = xlWS.Range("A2:A126")
rng.copy
xlWB.Close False
xlApp.Quit
Set rng = Nothing
Set xlWS = Nothing
Set xlWB = Nothing
Set xlApp = Nothing
End Sub
|
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Copy Specific Text String To Clipboard At End Of Macro
|
et_33 | Excel Programming | 8 | 10-11-2022 06:24 AM |
| Need to copy specific formated text from Word and paste from clipboard into a console application | Userx | Word VBA | 0 | 10-09-2020 05:58 AM |
Find & selected paras with highlighted text & copy to clipboard
|
marceepoo | Word VBA | 1 | 09-14-2012 08:20 PM |
Mark text in a text box and copy to clipboard (with button)
|
ArthurM | PowerPoint | 4 | 02-19-2012 11:33 AM |
copy without using clipboard?
|
g48dd | Excel | 3 | 07-16-2011 10:28 PM |