ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Can you call VBScript code from VBA? (https://www.excelbanter.com/excel-programming/331805-can-you-call-vbscript-code-vba.html)

John Keith[_2_]

Can you call VBScript code from VBA?
 
The following Code stored in a text file with a .VBS extension calls in the
file details I want to access and eventually update. The file detail I am
trying to change is "Track Number" (for music files recorded from a CD) the
FileSystemObject does not return this item in its structure.

The script works by dragging and dropping a folder onto the .VBS icon. It
was writing the data out to a text file (the code for that was snipped-out).

How do I modify the code so that I can pass the folder in as string data.

Set objShell = CreateObject("Shell.Application")
Set Ag=Wscript.Arguments
Set Fldr=objShell.NameSpace(Ag(0))
Set FldrItems=Fldr.Items
' shows the heading names... up to 50 of them
For x = 0 to 50
t1 = t1 & Fldr.GetDetailsOf(vbnull, x) & vbtab
Next
ts.write FLDR.self.path &vbcrlf
ts.Write T1 & vbcrlf
T1=""

'shows the data stored in each of the file's details
For Each FldrItem in FldrItems
For x = 0 to 50
t1 = t1 & Fldr.GetDetailsOf(FldrItem, x) & vbtab
Next
Next

*********
Is there some way to have the fso return ALL file details? I could use it,
but so far namespace is the only method I have found that can get me to the
specific data I want to see/update.

And I run almost all my code from Excel-VBA.
(im still very new to VB and scripting)
--
Regards,
John

Tushar Mehta

Can you call VBScript code from VBA?
 
Converted to VBA and lightly tested:
Option Explicit

Sub testIt()
Dim objShell, Fldr, FldrItems, x, ts, t1, FldrItem
Set objShell = CreateObject("Shell.Application")
'Set Ag = Wscript.Arguments
'Set Fldr = objShell.Namespace(Ag(0))
Set Fldr = objShell.Namespace("c:\temp")
Set FldrItems = Fldr.Items
' shows the heading names... up to 50 of them
For x = 0 To 50
t1 = t1 & Fldr.GetDetailsOf(vbNull, x) & vbTab
Next
Debug.Print Fldr.self.Path & vbCrLf
Debug.Print t1 & vbCrLf
t1 = ""

'shows the data stored in each of the file's details
For Each FldrItem In FldrItems
t1 = ""
For x = 0 To 50
t1 = t1 & Fldr.GetDetailsOf(FldrItem, x) & vbTab
Next
Debug.Print t1
Next
End Sub

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions

In article ,
says...
The following Code stored in a text file with a .VBS extension calls in the
file details I want to access and eventually update. The file detail I am
trying to change is "Track Number" (for music files recorded from a CD) the
FileSystemObject does not return this item in its structure.

The script works by dragging and dropping a folder onto the .VBS icon. It
was writing the data out to a text file (the code for that was snipped-out).

How do I modify the code so that I can pass the folder in as string data.

Set objShell = CreateObject("Shell.Application")
Set Ag=Wscript.Arguments
Set Fldr=objShell.NameSpace(Ag(0))
Set FldrItems=Fldr.Items
' shows the heading names... up to 50 of them
For x = 0 to 50
t1 = t1 & Fldr.GetDetailsOf(vbnull, x) & vbtab
Next
ts.write FLDR.self.path &vbcrlf
ts.Write T1 & vbcrlf
T1=""

'shows the data stored in each of the file's details
For Each FldrItem in FldrItems
For x = 0 to 50
t1 = t1 & Fldr.GetDetailsOf(FldrItem, x) & vbtab
Next
Next

*********
Is there some way to have the fso return ALL file details? I could use it,
but so far namespace is the only method I have found that can get me to the
specific data I want to see/update.

And I run almost all my code from Excel-VBA.
(im still very new to VB and scripting)



All times are GMT +1. The time now is 01:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com