Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-16-2015, 06:29 AM
gmayor's Avatar
gmayor gmayor is offline macro to add brackets to each line and add single quotes to each word in the line Windows 7 64bit macro to add brackets to each line and add single quotes to each word in the line Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,145
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

In my original code the paragraph is split with



Code:
vWord = Split(oRng.Text, Chr(32))
i.e. it splits at the space character 'Chr(32)' between the 'words'. However it can only split at spaces if there are spaces, and if you don't get the commas and single quotes, the 'spaces' are not space character 32, but probably non-breaking spaces 'Chr(160)'.

Change the 32 to 160 and see if that fixes it. If not, then, as Andrew indicates, we need to see a document sample.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #2  
Old 02-16-2015, 07:38 AM
bracketandquotes bracketandquotes is offline macro to add brackets to each line and add single quotes to each word in the line Windows 8 macro to add brackets to each line and add single quotes to each word in the line Office 2010 32bit
Novice
macro to add brackets to each line and add single quotes to each word in the line
 
Join Date: Feb 2015
Posts: 8
bracketandquotes is on a distinguished road
Default

It works . Many thanks Graham for taking the time and having the patience to do up the code.

Many thanks also to Andrew and Paul for taking the time to do up the codes.

You all have been a great help on this

David
Reply With Quote
  #3  
Old 02-16-2015, 03:51 PM
Guessed's Avatar
Guessed Guessed is offline macro to add brackets to each line and add single quotes to each word in the line Windows 7 32bit macro to add brackets to each line and add single quotes to each word in the line Office 2010 32bit
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,187
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

And based on your new information of the tab separator, my suggestion would be
Code:
Sub SQLiser()
  Dim oPara As Paragraph
  Dim oRng As Range, oParaRng As Range
  
  Set oRng = ActiveDocument.Range
  oRng.Text = Replace(oRng.Text, vbTab, "', '")
  For Each oPara In oRng.Paragraphs
    Set oParaRng = oPara.Range
    oParaRng.MoveEnd Unit:=wdCharacter, Count:=-1
    oParaRng.Text = "('" & oParaRng.Text & "'),"
  Next oPara
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
macro to add brackets to each line and add single quotes to each word in the line How many points is line spacing 'single'? Ugeen Word 2 11-24-2013 03:14 PM
macro to add brackets to each line and add single quotes to each word in the line Changing single-quotes to double-quotes Bobosmite Word 5 04-15-2013 06:40 AM
From the command line, how do I run a Word macro? jdockstader Word 7 02-04-2013 06:09 AM
Single Line Spacing for Short Lists? tatihulot Word 2 04-20-2010 02:53 PM
macro to add brackets to each line and add single quotes to each word in the line Different alignments in a single line George99 Word 2 01-24-2010 05:49 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:54 PM.


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