Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-17-2020, 01:05 AM
alex100 alex100 is offline Pass variables to the 'EditPaste' sub Windows 7 64bit Pass variables to the 'EditPaste' sub Office 2016
Novice
Pass variables to the 'EditPaste' sub
 
Join Date: May 2020
Posts: 29
alex100 is on a distinguished road
Default Pass variables to the 'EditPaste' sub


I have a subroutine that is executed when pressing CTRL-V (paste function). It's called 'EditPaste'.

I also have a second subroutine from which I need to make a call to the 'EditPaste' sub. With this call, I need to pass a variable from this second sub to the 'EditPaste' sub. For more clarity, here's the code...

Code:
Sub EditPaste(variable)
  
  'code here...

End Sub
Code:
Sub second_subroutine

  Call EditPaste("value")

End Sub
It works well, meaning that I can indeed access the variable value inside the EditPaste subroutine.

The problem is that the 'EditPaste' sub will no longer execute when pressing the CTRL+V key combination. So it executes well when using the 'Sub EditPaste' code, but not at all when using the 'Sub EditPaste(variable)' code.

How can I pass variables to 'EditPaste' and be able to execute it with CTRL+V at the same time?

Alex
Reply With Quote
  #2  
Old 05-17-2020, 03:28 PM
gmaxey gmaxey is offline Pass variables to the 'EditPaste' sub Windows 10 Pass variables to the 'EditPaste' sub Office 2016
Word MVP 2003-2009
 
Join Date: May 2010
Location: Marble, NC
Posts: 1,034
gmaxey will become famous soon enoughgmaxey will become famous soon enough
Default

Code:
Sub EditPaste()
  MyEditPaste
End Sub

Sub MyEditPaste(Optional varPassed As String)
  If Not varPassed = vbNullString Then
    MsgBox varPassed
  Else
    Selection.Paste
  End If
End Sub

Sub OtherRoutine()
  MyEditPaste "Test"
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 05-18-2020, 01:09 AM
alex100 alex100 is offline Pass variables to the 'EditPaste' sub Windows 7 64bit Pass variables to the 'EditPaste' sub Office 2016
Novice
Pass variables to the 'EditPaste' sub
 
Join Date: May 2020
Posts: 29
alex100 is on a distinguished road
Default

Works great, thank you!

Alex
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I pass a field as a parameter via a URL? kelvinlewisuk1 Outlook 0 06-30-2016 08:30 AM
Array to iterate through variables and trap blank variables Marrick13 Word VBA 5 08-04-2015 06:19 AM
can word: make variables, find appropriate pages, fill out pages with variables, print only those 20GT Word VBA 1 10-15-2014 09:48 PM
Pass variables to the 'EditPaste' sub How to Pass Document to this Sub ilcaa72 Word VBA 1 01-28-2014 03:04 PM
How to pass parameters to a .msg file? HereNow Outlook 0 11-05-2012 10:38 AM

Other Forums: Access Forums - Senior Forums

All times are GMT -7. The time now is 02:30 AM.


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