Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Closed Thread
 
Thread Tools Display Modes
  #1  
Old 02-10-2014, 06:39 PM
saltlakebuffalo saltlakebuffalo is offline Windows 7 64bit Office 2010 32bit
Novice
send a string from Excel UserForm to Word
 
Join Date: Feb 2014
Posts: 11
saltlakebuffalo is on a distinguished road
Default send a string from Excel UserForm to Word

Hello, I am in Excel VBA UserForm. I have a long string text containing lots of chr(10) and chr (13) and I need to sent this string to a Word file. However after I sent I found lots of blank lines in the Word document and I had to manually "select all" and do "reduce the space between rows". Later I added a code to select the whole text in Word, but I don't know how to use "WholeStory" function to delete all these blank rows in the selected text. My code is as below (in Excel VBA):

Private Sub ScopeSendToWord
Dim objWordFile As Word.Application
Set objWordFile = New Word.Application
objWordFile.Documents.Add


objWordFile.ActiveDocument.Range.Text = txtScope (txtScope is a string text which I want to export to a Word file, the code works and I can see the content in Word file)
objWordFile.ActiveDocument.Range.Select (selecting text in Word file)
Selection.WholeStory (this is the code I added but I can't get through and I need help)
objWordFile.Visible=True
End Sub

Thank you so much.
Jason
  #2  
Old 02-10-2014, 11:01 PM
macropod's Avatar
macropod macropod is offline send a string from Excel UserForm to Word Windows 7 32bit send a string from Excel UserForm to Word Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

See my reply in your other thread: https://www.msofficeforums.com/word-...ry-method.html

Please don't post the same question in multiple forums. Thread closed.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Closed Thread



Similar Threads
Thread Thread Starter Forum Replies Last Post
send a string from Excel UserForm to Word 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
Excel Fomula to search for a string and display value from different column zeeshanbutt Excel 1 07-29-2012 12:48 AM
send a string from Excel UserForm to Word How to link userform to another word document SaneMan Word VBA 5 10-14-2011 05:12 AM
VBA code to update record in Access 2003 using Userform in Excel primmer3001 Excel Programming 0 08-29-2011 04:25 PM
cant send email directly from WORD (or excel) etodem Word 0 04-03-2009 04:59 PM

Other Forums: Access Forums

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