Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #31  
Old 09-27-2017, 06:30 AM
StephenRay StephenRay is offline Find This Or That On Line Six of Word Document Windows 7 64bit Find This Or That On Line Six of Word Document Office 2010 64bit
Advanced Beginner
Find This Or That On Line Six of Word Document
 
Join Date: Jan 2012
Location: Overland Park, Kansas
Posts: 53
StephenRay is on a distinguished road
Default

Ok! It works! I am passing a variable in a Sub like this:



CallingSub
'This part clears the clipboard
Dim clipboard As MSForms.DataObject
Set clipboard = New MSForms.DataObject
clipboard.SetText ""
clipboard.PutInClipboard

If InStr(StrTxt4, "FSA") > 0 Then
Call FSA(clipboard)

And the called sub looks like this:

Sub FSA(clipboard)
'
' FSA Macro
Dim StrTxt9 As String
StrTxt9 = ActiveDocument.Paragraphs(9).Range.Text
.....more code....
End sub

And my question is this. Best Practices say to use a Function rather than a called sub? Is that right? Ok, but whyis a Function best? I don't get it. For development purposes, I got it going just calling a sub.

Thanks
Reply With Quote
  #32  
Old 09-27-2017, 07:23 AM
slaycock slaycock is offline Find This Or That On Line Six of Word Document Windows 7 64bit Find This Or That On Line Six of Word Document Office 2013
Expert
 
Join Date: Sep 2013
Posts: 256
slaycock is on a distinguished road
Default

Its a programming style issue NOT a compulsory part of VBA.

You are free to use sub if you wish.
Reply With Quote
  #33  
Old 09-29-2017, 07:51 AM
StephenRay StephenRay is offline Find This Or That On Line Six of Word Document Windows 7 64bit Find This Or That On Line Six of Word Document Office 2010 64bit
Advanced Beginner
Find This Or That On Line Six of Word Document
 
Join Date: Jan 2012
Location: Overland Park, Kansas
Posts: 53
StephenRay is on a distinguished road
Default

Slaycock, Ahh.... That makes sense, I couldn't see any good reason why...
By the way, I have got one Sub that calls about 25 other Subs depending on which U.S. Agency is involved. Within each of these 25 Subs there are various conditions tested to see which Email address must be used.
It is a work of art! Calling Subs and passing variables, -I learned a lot. Thanks!
It will be easy to maintain and save some time.
Reply With Quote
  #34  
Old 09-29-2017, 02:01 PM
slaycock slaycock is offline Find This Or That On Line Six of Word Document Windows 7 64bit Find This Or That On Line Six of Word Document Office 2013
Expert
 
Join Date: Sep 2013
Posts: 256
slaycock is on a distinguished road
Default

Glad to hear you are making progress.

Do you feel brave enough to share your code with us?
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find This Or That On Line Six of Word Document Black line that is in word document that won't go away ! seyzna Word 7 05-22-2023 10:57 AM
Find This Or That On Line Six of Word Document Won't find Word document wblock@cnu.edu Word 4 08-23-2017 06:11 PM
Find This Or That On Line Six of Word Document Cannot find my word document - saved to usb mssodium1219 Word 3 04-01-2015 04:24 AM
Find This Or That On Line Six of Word Document Bad view when using Find and Find & Replace - Word places found string on top line paulkaye Word 4 12-06-2011 11:05 PM
Word 2003 cuts the last line of my document off wordboy9317 Word 0 10-12-2009 08:44 AM

Other Forums: Access Forums

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