Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-28-2014, 11:44 AM
ilcaa72 ilcaa72 is offline How to Pass Document to this Sub Windows 7 64bit How to Pass Document to this Sub Office 2010 64bit
Novice
How to Pass Document to this Sub
 
Join Date: Jan 2014
Posts: 27
ilcaa72 is on a distinguished road
Default How to Pass Document to this Sub

I am not the most versed in VBA so needed some help. I have this function but I am not sure how to pass the current document as the input.



Here is the beggining of the procedure, please advise how i reference the current document as the "Sentences" to use as the input to this function..

Code:
 Function GetSentences(ByVal Sentences As String) As Collection

'Delete space
 Sentences = Trim(Sentences)
 
 Dim sList As New Collection
 Dim RE As Object, REMatches As Object
 Set RE = CreateObject("vbscript.regexp")
    With RE
        .MultiLine = False
        .Global = True
        .IgnoreCase = False
        .Pattern = "(\S.+?[.?])(?=\s+|$)\s"
    End With
 
....
 
End Function
Reply With Quote
  #2  
Old 01-28-2014, 03:04 PM
macropod's Avatar
macropod macropod is offline How to Pass Document to this Sub Windows 7 32bit How to Pass Document to this Sub Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

What you'd pass to that function is not the document, but its content, as in:
GetSentences (ActiveDocument.Range.Text)
Instead of ActiveDocument, you might specify a particular document; you might also specify a particular range from that document rather than all of it.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Pass Document to this Sub split word document based on bookmarks with each new document title of the bookmark megatronixs Word VBA 9 09-05-2020 02:29 PM
How to Pass Document to this Sub Can pass .expression as a parameter? tinfanide PowerPoint 4 12-28-2012 06:14 PM
How to pass parameters to a .msg file? HereNow Outlook 0 11-05-2012 10:38 AM
Office 2010 Excel Full pass raineraus Excel 1 09-19-2012 12:55 PM
How to Pass Document to this Sub Anchoring a section break to the bottom of a page, and having a table pass over it??? h3rk Word Tables 1 11-20-2009 07:34 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:11 PM.


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