Sign Up |  Live StatsLive Stats    Articles 38,747| Comments 189,196| Members 19,978, Newest CuriousMan| Online 290
Home Contact
 (Forgotten?): 
    Sikhism
    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: 0 USD (0%)
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, 11:40 AM
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, 11:40 AM
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, 11:40 AM
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, 11:40 AM
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, 09: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 07:38 AM
Problem with FindFirst Method j Information Technology 4 28-Jul-2006 07:36 AM
Problem with Execute method on linked SQL Server tables scarymountains@gmail.com Information Technology 1 28-Jul-2006 07:20 AM
Shell to app in the same folder Bob Richardson Information Technology 4 19-Nov-2005 20:00 PM
Using the Shell function Richard John Information Technology 1 27-Oct-2005 07: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
Canada allows Sikh...
Today 10:02 AM
3 Replies, 74 Views
UPDATED! Dr. Prabjot...
By Abneet
Today 09:16 AM
12 Replies, 821 Views
Samagam... wearing...
By Akasha
Yesterday 19:51 PM
5 Replies, 120 Views
A Proposed Hair Sampling...
By Akasha
19-Apr-2014 12:30 PM
7 Replies, 230 Views
Young Sikhs in Maryland...
19-Apr-2014 12:21 PM
0 Replies, 78 Views
Inter-Religious...
19-Apr-2014 09:13 AM
35 Replies, 5,978 Views
What is Naam?
18-Apr-2014 11:24 AM
3 Replies, 160 Views
Indo-Canadian...
18-Apr-2014 09:55 AM
0 Replies, 93 Views
When Guru Gobind Singh...
18-Apr-2014 00:11 AM
2 Replies, 198 Views
Adjectives to describe...
17-Apr-2014 22:49 PM
6 Replies, 159 Views
Fools Who Wrangle Over...
16-Apr-2014 17:59 PM
1,261 Replies, 139,275 Views
Sikhs honour Police...
15-Apr-2014 19:49 PM
0 Replies, 108 Views
Vaisakhi resolution...
15-Apr-2014 19:45 PM
0 Replies, 81 Views
Thought of the Moment!
14-Apr-2014 10:41 AM
286 Replies, 23,078 Views
Going Back To India :)
By Akasha
14-Apr-2014 04:45 AM
4 Replies, 244 Views
» Books You Should Read...
Powered by vBadvanced CMPS v3.2.3
All times are GMT +5.5. The time now is 11:06 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-2014, All Rights Reserved. Sikh Philosophy Network


Page generated in 0.27509 seconds with 34 queries