Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-21-2016, 05:35 AM
Philip1 Philip1 is offline Trying to read CSV file and place values into word bookmarks Windows 7 64bit Trying to read CSV file and place values into word bookmarks Office 2010 64bit
Novice
Trying to read CSV file and place values into word bookmarks
 
Join Date: Oct 2016
Posts: 3
Philip1 is on a distinguished road
Default Trying to read CSV file and place values into word bookmarks

I have the following code which doesn't seem to do anything on the above.

At this moment in time I'm just trying to read the CSV and use MSG Box to display field values.

Can you please help?


Option Explicit

Private Sub BtnLoad_Click()
On Error GoTo Err_Catch

Err_Catch:
Resume Next

Dim Customer, Salutation, FirstName, Surname, Telephone, Mobile, SiteMobile, EMail, Address1, Address2, Address3, TownCity, _
PostCode, SageNo, CurrentStatus, DTA, SLADate, Services, BagLimit, Charge, ChargePeriod, Sites, strSQL As String
Dim Bookmark, CurrentField As Range

Dim CSVConnection As New ADODB.Connection
Dim rs As New ADODB.Recordset

Set CSVConnection = New ADODB.Connection
Set rs = New ADODB.Recordset

CSVConnection.Open "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" _
& path & ";Extensions=asc,csv,tab,txt;HDR=NO;Persist Security Info=False"

strSQL = "SELECT * FROM Customer Report.csv"

rs.Open strSQL, CSVConnection, adOpenStatic, adLockReadOnly

Do While Not rs.EOF
MsgBox rs(0)
rs.MoveNext
Loop

If rs.RecordCount > 0 Then
Do
Customer = rs("Customer")
Salutation = rs("Salutation")
FirstName = rs("First Name")
Surname = rs("Surname")
Telephone = rs("Telephone")
Mobile = rs("Mobile")
SiteMobile = rs("Site Mobile")
EMail = rs("EMail")
Address1 = rs("Address 1")
Address2 = rs("Address 2")
Address3 = rs("Address 3")
PostCode = rs("Post Code")


SageNo = rs("Sage Account")
CurrentStatus = rs("Current Status")
DTA = rs("DTA Service")
SLADate = rs("SLA Date")
Services = rs("Current Services")
BagLimit = rs("Bag Limit")
Charge = rs("Charge")
ChargePeriod = rs("Charge Period")
Sites = rs("Sites")

rs.MoveNext
Loop Until rs.EOF
End If

rs.Close
Set CSVConnection = Nothing

End Sub
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Paste from one page to another doesnt place in the same place MrShhh Visio 0 09-21-2016 05:47 AM
Trying to read CSV file and place values into word bookmarks Form updating Bookmarks - writes to the bookmarks multiple times PeterPlys Word VBA 13 01-14-2015 06:41 AM
Trying to read CSV file and place values into word bookmarks Read only file NienkeG Word 2 08-03-2014 03:57 PM
Trying to read CSV file and place values into word bookmarks editing a number/text at one place and changes taking place wherever it appears anurag.butoliya Word 1 06-14-2014 06:27 PM
Trying to read CSV file and place values into word bookmarks Why the "day" is not inserted as we read values from Excel to Word? Jamal NUMAN Word 8 09-04-2011 07:48 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:58 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