Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-17-2023, 05:15 PM
syl3786 syl3786 is offline VBA Copy Text issues Windows 10 VBA Copy Text issues Office 2019
Advanced Beginner
VBA Copy Text issues
 
Join Date: Jan 2023
Posts: 97
syl3786 is on a distinguished road
Default


Quote:
Originally Posted by gmayor View Post
The second link includes a code listing to read Excel data to an array.
This one? Should I remove the Private Function WriteToWorksheet? How to do that?

Code:
Private Function xlFillArray(strWorkbook As String, _
                             strRange As String) As Variant
'Graham Mayor - http://www.gmayor.com - 24/09/2016
Dim RS As Object
Dim CN As Object
Dim iRows As Long

strRange = strRange & "$]"    'Use this to work with a named worksheet
    'strRange = strRange & "]" 'Use this to work with a named range
    Set CN = CreateObject("ADODB.Connection")

    'Set HDR=NO for no header row
    CN.Open ConnectionString:="Provider=Microsoft.ACE.OLEDB.12.0;" & _
                              "Data Source=" & strWorkbook & ";" & _
                              "Extended Properties=""Excel 12.0 Xml;HDR=YES;IMEX=1"""

    Set RS = CreateObject("ADODB.Recordset")
    RS.Open "SELECT * FROM [" & strRange, CN, 2, 1

    With RS
        .MoveLast
        iRows = .RecordCount
        .MoveFirst
    End With
    xlFillArray = RS.GetRows(iRows)
    If RS.State = 1 Then RS.Close
    Set RS = Nothing
    If CN.State = 1 Then CN.Close
    Set CN = Nothing
lbl_Exit:
    Exit Function
End Function
Reply With Quote
Reply

Tags
copy text, vba word to excel



Similar Threads
Thread Thread Starter Forum Replies Last Post
Issues with a copy of a Contents Table! KirstyAmanda Word 2 07-20-2020 02:51 PM
VBA Copy Text issues Font issues when copy content from MS Word. ArchanaV Word 3 06-29-2016 01:02 PM
Issues with text in circle shapes that I am having damefrombrum Word 0 12-01-2015 08:05 PM
Page Up & Copy/Paste Issues weamish Word 10 02-01-2014 08:25 PM
VBA Copy Text issues Copy and Paste issues in Outlook 2007 Oncilla Outlook 6 12-13-2010 01:00 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:07 PM.


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