Sign Up |  Live StatsLive Stats    Articles 38,991| Comments 191,988| Members 20,116, Newest Basil| Online 304
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
Can we ever see Sri Guru...
Today 10:59 AM
35 Replies, 783 Views
Sikhs panic after target...
14-Sep-2014 11:59 AM
0 Replies, 87 Views
09-11-2014
13-Sep-2014 23:50 PM
1 Replies, 267 Views
SIKH WOMEN: Bypassed by...
By Ishna
13-Sep-2014 13:58 PM
5 Replies, 536 Views
Plane leaves in 4 hrs...
13-Sep-2014 10:47 AM
7 Replies, 349 Views
Gurdwara in San...
By raj008
13-Sep-2014 09:14 AM
2 Replies, 113 Views
Types of Karas
12-Sep-2014 20:02 PM
3 Replies, 177 Views
Vote for Simran Jeet...
12-Sep-2014 00:34 AM
1 Replies, 146 Views
Is it OK to see Guru...
11-Sep-2014 06:49 AM
17 Replies, 597 Views
Fateful journey of a...
10-Sep-2014 09:42 AM
0 Replies, 130 Views
What Are Your Views of...
10-Sep-2014 05:25 AM
8 Replies, 847 Views
The Gender Trap
09-Sep-2014 08:59 AM
6 Replies, 360 Views
Online Porn Boom:...
09-Sep-2014 08:45 AM
6 Replies, 1,147 Views
Sikhs Prone to Vitamin D...
08-Sep-2014 11:36 AM
26 Replies, 5,294 Views
Sharing a bit about my...
07-Sep-2014 07:16 AM
7 Replies, 324 Views
» Books You Should Read...
Powered by vBadvanced CMPS v3.2.3
All times are GMT +5.5. The time now is 18:56 PM.
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.27470 seconds with 34 queries