Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #16  
Old 12-05-2013, 03:41 PM
BobBridges's Avatar
BobBridges BobBridges is offline Can a function or sub be called using a variable name? Windows 7 64bit Can a function or sub be called using a variable name? Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

Ah, excellent! Thanks, Paul.



("Ho, hum"—lol)
Reply With Quote
  #17  
Old 12-05-2013, 07:51 PM
omahadivision omahadivision is offline Can a function or sub be called using a variable name? Windows 7 32bit Can a function or sub be called using a variable name? Office 2007
Novice
Can a function or sub be called using a variable name?
 
Join Date: Oct 2012
Posts: 28
omahadivision is on a distinguished road
Smile

Thanks! Macropod's last coding did exactly what I wanted it to. I had to remove "ThisWorkbook." from MacroName and then it ran like a charm! Sorry about the delay in responding; there's been some rough weather in my part of the country recently!
Reply With Quote
  #18  
Old 12-05-2013, 08:05 PM
macropod's Avatar
macropod macropod is offline Can a function or sub be called using a variable name? Windows 7 32bit Can a function or sub be called using a variable name? 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

Quote:
Originally Posted by omahadivision View Post
I had to remove "ThisWorkbook." from MacroName and then it ran like a charm!
Whilst it might work well enough without "ThisWorkbook.", you still should reference the workbook from which the code is to be run, so you don't run into problems when multiple workbooks are open and: (a) the macro you want to run isn't in the active workbook; and/or (b) there is more than one sub of the same name in the different workbooks.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #19  
Old 12-05-2013, 08:14 PM
BobBridges's Avatar
BobBridges BobBridges is offline Can a function or sub be called using a variable name? Windows 7 64bit Can a function or sub be called using a variable name? Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Thumbs up

I'm with macropod on this; every time I get into the habit of using unqualified objects, I end up shooting myself in the foot and go back to qualifying everything. Well, almost everything.

On the other hand, this problem tends to be self-correcting. Some day, maybe soon, you'll spend a frustrating hour or whole afternoon trying to figure out why something really simple is producing the wrong results. When you realize what it is, you'll remember what we said. One or two of those and I expect you'll decide it's worth the extra work.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can a function or sub be called using a variable name? object variable or with block variable not set MJP143 Excel 1 02-11-2013 05:07 AM
Can a function or sub be called using a variable name? Run-time error '91': Object variable or With block variable not set tinfanide Excel Programming 2 06-10-2012 10:17 AM
excel where is procedure being called from davids67 Excel Programming 1 11-18-2011 06:48 AM
Can a function or sub be called using a variable name? What is this symbol called as? Franky Word 3 11-12-2011 08:16 AM
What is this right-click sub-menu called? wornways Word 3 08-13-2010 09:17 PM

Other Forums: Access Forums

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