Sign Up |  Live StatsLive Stats    Articles 39,042| Comments 192,372| Members 20,177, Newest joiner10| Online 306
Home Contact
 (Forgotten?): 
    Chaar Sahibzaade
    For best SPN experience, use Firefox Internet Browser!


                                                                   Your Banner Here!    




Click Here to Register/Sign Up Daily Hukamnama Member Blogs Downloads Website Navigation Help Fonts Tags
Sikh Philosophy Network » Sikh Philosophy Network » Current News » Information Technology » Problem using Shell NameSpace method in VBA

Problem using Shell NameSpace method in VBA

Our Donation Goal : Why Donate? : Donate Today! : Donate Anonymously (ਗੁਪਤ) : Our Family of Supporters
Goal this month: 300 USD, Received: 25 USD (8%)
Please Donate...
       

Tags
problem, using, shell, namespace, method, vba
Reply Post New Topic In This Forum Stay Connected to Sikhism, Click Here to Register Now!
  #1 (permalink)  
Old 01-Nov-2005, 12:40 PM
thor.carlson@gmail.com's Avatar thor.carlson@gmail.com
Guest
 
Posts: n/a
   
   
Problem using Shell NameSpace method in VBA

  Donate Today!   Email to Friend  Tell a Friend   Show Printable Version  Print   Contact sikhphilosophy.net Administraion for any Suggestions, Ideas, Feedback.  Feedback  

Register to Remove Advertisements
Doubtless this is a ridiculous newbie question in which case apologies
in advance.

I'm working from VBA in Microsoft Access and want to operate on a file
folder on the local computer. The NameSpace method creates and returns
a Folder object for the specified folder.
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/information-technology/6265-problem-using-shell-namespace-method-vba.html

Looking at the Test procedure below, can someone explain to me why I
get "Nothing" back when I call NameSpace with a string variable, but I
get a Folder object back when I call NamesSpace with a string literal?

Private Sub Test()

Dim myApp As Object
Dim myFolder
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6265
Dim strTemp As String

strTemp = "c:\temp2"

Set myApp = CreateObject("Shell.Application")
Set myFolder = myApp.NameSpace(strTemp) ' returns Nothing
Set myFolder = myApp.NameSpace("c:\temp2") ' returns a Folder
object

End Sub



Thanks in advance.



Do you agree or disagree with the writer above? Why not share your immediate thoughts with us! Login Now! or Sign Up Today! to share your views... Gurfateh!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-Nov-2005, 12:40 PM
Gitche Gumee's Avatar Gitche Gumee
Guest
 
Posts: n/a
   
   
RE: Problem using Shell NameSpace method in VBA

Your string variable is not equivalent to the string literal. It's missing
the required quotes:

strTemp = """ & "c:\temp2" & """



"thor.carlson@gmail.com" wrote:
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6265

> Doubtless this is a ridiculous newbie question in which case apologies
> in advance.
>
> I'm working from VBA in Microsoft Access and want to operate on a file
> folder on the local computer. The NameSpace method creates and returns
> a Folder object for the specified folder.
>
> Looking at the Test procedure below, can someone explain to me why I
> get "Nothing" back when I call NameSpace with a string variable, but I
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6265
> get a Folder object back when I call NamesSpace with a string literal?
>
> Private Sub Test()
>
> Dim myApp As Object
> Dim myFolder
> Dim strTemp As String
>
> strTemp = "c:\temp2"
>
> Set myApp = CreateObject("Shell.Application")
> Set myFolder = myApp.NameSpace(strTemp) ' returns Nothing
> Set myFolder = myApp.NameSpace("c:\temp2") ' returns a Folder
> object
>
> End Sub
>
>
>
> Thanks in advance.
>
>

Reply With Quote
  #3 (permalink)  
Old 01-Nov-2005, 12:40 PM
Dirk Goldgar's Avatar Dirk Goldgar
Guest
 
Posts: n/a
   
   
Re: Problem using Shell NameSpace method in VBA

wrote in message
news:1130774508.573242.245590@f14g2000cwb.googlegr oups.com
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6265
> Doubtless this is a ridiculous newbie question in which case apologies
> in advance.
>
> I'm working from VBA in Microsoft Access and want to operate on a file
> folder on the local computer. The NameSpace method creates and
> returns a Folder object for the specified folder.
>
> Looking at the Test procedure below, can someone explain to me why I
> get "Nothing" back when I call NameSpace with a string variable, but I
> get a Folder object back when I call NamesSpace with a string literal?
>
> Private Sub Test()
>
> Dim myApp As Object
> Dim myFolder
> Dim strTemp As String
>
> strTemp = "c:\temp2"
>
> Set myApp = CreateObject("Shell.Application")
> Set myFolder = myApp.NameSpace(strTemp) ' returns Nothing
> Set myFolder = myApp.NameSpace("c:\temp2") ' returns a Folder
> object
>
> End Sub


I'm not an expert in this area, but I suspect that the string *variable*
is passed differently than the string literal -- and there can be no
implicit conversion because you're using late binding. You can force
evaluation of the string variable and pass the result of that evaluation
to the NameSpace method by wrapping the variable name in an extra set of
parentheses, like this:

Set myFolder = myApp.NameSpace((strTemp))
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6265

That worked in my test.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


Reply With Quote
  #4 (permalink)  
Old 01-Nov-2005, 12:40 PM
Thor's Avatar Thor
Guest
 
Posts: n/a
   
   
Re: Problem using Shell NameSpace method in VBA

Excellent! Dirk's solution worked for me. Is there a technical name
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6265
for this "forced evaluation" technique so I can study up?

Reply With Quote
  #5 (permalink)  
Old 02-Nov-2005, 10:47 AM
Dirk Goldgar's Avatar Dirk Goldgar
Guest
 
Posts: n/a
   
   
Re: Problem using Shell NameSpace method in VBA

  Donate Today!  
"Thor" wrote in message
news:1130780081.032834.139030@g43g2000cwa.googlegr oups.com
> Excellent! Dirk's solution worked for me. Is there a technical name
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6265
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6265
> for this "forced evaluation" technique so I can study up?


I was just looking through the VB help, and I couldn't find a topic that
even mentions it. I learned it somewhere along the way, but I don't
know where -- probably from a newsgroup post. In general, putting
parentheses around a variable name -- aside from parentheses that are
otherwise required by the syntax of an array-element reference or a
subroutine/function call -- forces the evaluation of that variable.
Most often, this only makes a difference with object variables, where it
distinguishes between the object itself and the *value* of the object,
but you found a situation where it mattered even with a normal variable.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


Reply With Quote
   Click Here to Donate Now!
Related Topics...
Thread Thread Starter Forum Replies Last Post
Access 2003 Call Shell error Andybev Information Technology 0 28-Jul-2006 08:38 AM
Problem with FindFirst Method j Information Technology 4 28-Jul-2006 08:36 AM
Problem with Execute method on linked SQL Server tables scarymountains@gmail.com Information Technology 1 28-Jul-2006 08:20 AM
Shell to app in the same folder Bob Richardson Information Technology 4 19-Nov-2005 21:00 PM
Using the Shell function Richard John Information Technology 1 27-Oct-2005 08:58 AM


Support Us!
Become a Promoter!
Gurfateh ji, you can become a SPN Promoter by Donating as little as $10 each month. With limited resources & high operational costs, your donations make it possible for us to deliver a quality website and spread the teachings of the Sri Guru Granth Sahib Ji, to serve & uplift humanity. Every contribution counts. Donate Generously. Gurfateh!
ReplyPost New Topic In This Forum Stay Connected to Sikhism, Click Here to Register Now!

Bookmarks


(View-All Members who have read this thread : 0
There are no names to display.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

» Active Discussions
Can I wear a Dumalla
Yesterday 13:08 PM
13 Replies, 773 Views
Fools Who Wrangle Over...
Yesterday 00:18 AM
1,317 Replies, 157,750 Views
Research Shows NFL...
By linzer
23-Nov-2014 06:55 AM
0 Replies, 112 Views
Lost Treasures of the...
21-Nov-2014 08:55 AM
0 Replies, 170 Views
Why we celebrate Guru...
20-Nov-2014 18:18 PM
29 Replies, 1,209 Views
French Honor for British...
16-Nov-2014 03:48 AM
0 Replies, 209 Views
What should be the AIM...
14-Nov-2014 16:11 PM
25 Replies, 1,090 Views
First Turbaned Sikh...
12-Nov-2014 03:02 AM
5 Replies, 532 Views
Is Sikh Philosophy...
29-Oct-2014 20:07 PM
7 Replies, 595 Views
Destination Wedding in...
29-Oct-2014 19:41 PM
2 Replies, 330 Views
» Books You Should Read...
Powered by vBadvanced CMPS v3.2.3
All times are GMT +5.5. The time now is 10:52 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2 Copyright 2004-2015, All Rights Reserved. Sikh Philosophy Network


Page generated in 0.27415 seconds with 34 queries