Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-10-2023, 12:01 AM
yanyan9896 yanyan9896 is offline Copy Text To Clipboard issue Windows 10 Copy Text To Clipboard issue Office 2019
Novice
Copy Text To Clipboard issue
 
Join Date: Oct 2023
Posts: 13
yanyan9896 is on a distinguished road
Unhappy Copy Text To Clipboard issue

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
I would be grateful for any guidance or suggestions to improve this code and make it work as intended. Thank you in advance for your assistance.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy Text To Clipboard issue 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
Copy Text To Clipboard issue Find & selected paras with highlighted text & copy to clipboard marceepoo Word VBA 1 09-14-2012 08:20 PM
Copy Text To Clipboard issue Mark text in a text box and copy to clipboard (with button) ArthurM PowerPoint 4 02-19-2012 11:33 AM
Copy Text To Clipboard issue copy without using clipboard? g48dd Excel 3 07-16-2011 10:28 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:31 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft