Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-10-2015, 01:02 PM
equalizer88 equalizer88 is offline Word VBA need apostrophe for string but commented out Windows 7 32bit Word VBA need apostrophe for string but commented out Office 2010 32bit
Novice
Word VBA need apostrophe for string but commented out
 
Join Date: Jul 2015
Posts: 15
equalizer88 is on a distinguished road
Default Word VBA need apostrophe for string but commented out

Trying to insert text at beginning of all text files in folder.
part of relevant code below. if wrd = "start" no issues.
but my text is long.

1. First problem is that after \n editor inserts " mark at end of first line. Why?
2. The other lines start with ' (such as 'Text1')
so obviously, the lines are commented out.

What is easy way to insert long text with ' marks?






Dim oRng As Range
Dim i As Long
Set oRng = DocSrc.Range 'oRng set to entire document
wrd = "030100 FILL, DECLARE, GLOBAL, DECIMAL, LIST, \n 'zzz-NUM', 'yyy-NUM' \n," _
'Text1', 'Text2', 'Text3', _
'Text4', 'DESC1', 'DESC2', 'DESC3', _
'DESC4'
oRng.InsertBefore wrd
Reply With Quote
  #2  
Old 08-10-2015, 05:29 PM
macropod's Avatar
macropod macropod is offline Word VBA need apostrophe for string but commented out Windows 7 64bit Word VBA need apostrophe for string but commented out Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

If you're going to break lines apart like that, you need to do more than insert the continuation underscore - you need:

Code:
wrd = "030100 FILL, DECLARE, GLOBAL, DECIMAL, LIST, \n 'zzz-NUM', 'yyy-NUM' \n," & _
  "'Text1', 'Text2', 'Text3'," & _
  "'Text4', 'DESC1', 'DESC2', 'DESC3'," & _
  "'DESC4'"
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 08-12-2015, 10:05 AM
equalizer88 equalizer88 is offline Word VBA need apostrophe for string but commented out Windows 7 32bit Word VBA need apostrophe for string but commented out Office 2010 32bit
Novice
Word VBA need apostrophe for string but commented out
 
Join Date: Jul 2015
Posts: 15
equalizer88 is on a distinguished road
Default

Thanks so much. Of course I was trying to use \n as newline and that doesn't work. Need to use ASCII 10 to do that.
Also, trying to use FORMAT at beginning of string, that gave error, so just used empty " " & to use Format. Here is corrected version:

wrd = " " & Format(i, "000000") & " FILL, DECLARE, GLOBAL, DECIMAL, LIST, " & Chr(10) & _
" 'BLIN-NUM', 'CHAN-NUM'," & Chr(10) & _
" 'PCOF1', 'PCOF2', 'PCOF3', " & Chr(10) & _
" 'PCOF4', 'DESC1', 'DESC2', 'DESC3'," & Chr(10) & _
" 'DESC4', " & Chr(10)
oRng.InsertBefore wrd
Reply With Quote
Reply

Tags
comments, word vba

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Word VBA need apostrophe for string but commented out Word VBA - Save file as a string contained within the word (always same row and leng) RG87 Word VBA 1 05-21-2014 05:39 AM
Word VBA need apostrophe for string but commented out Way to search for a string in text file, pull out everything until another string? omahadivision Excel Programming 12 11-23-2013 12:10 PM
problems with apostrophe rbsalyer Word 2 09-01-2013 07:08 PM
apostrophe button spelling "apostrophe" birdfloyd Outlook 0 10-12-2011 07:35 AM
Outlook 2007 apostrophe glitch TPaul8705 Outlook 0 06-07-2011 08:23 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:50 AM.


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