How to define my file parent in vbs
Copy link to clipboard
Copied
Hi experts,
my jsx script like this:
var myFolder=Folder(app.activeDocument.fullName);
var myOpenFolder=Folder(myFolder.parent.fsName);
alert(myFolder.parent.fsName);
how to translate it into vbs?
thanks
regard
John
Copy link to clipboard
Copied
Hi John,
cannot help with the VB Script part.
FWIW: You should test if the active document is saved before using fullName.
Something like that:
var doc = app.documents[0];
if( doc.saved ){ var folderOfDoc = doc.fullName.parent };
Regards,
Uwe
Copy link to clipboard
Copied
Hi John,
you can try the code below I put together using the InDesign_ScriptingGuide_VB. I don't know vbScript and have no way to test it.
Set myInDesign = CreateObject("InDesign.Application")
If myInDesign.ActiveDocument.Saved = True Then
myActiveDocument = myInDesign.ActiveDocument
Set myFileSystemObject = CreateObject("Scripting.FileSystemObject")
myParentFolder = myFileSystemObject.GetFile(myActiveDocument).ParentFolder
MsgBox ("The folder containing the active document is: " & myParentFolder)
End If
Hope this helps you out.
Regards,
Mike
Copy link to clipboard
Copied
thank you Mike,
not working.
error on line 5
the myActiveDocument is not found.
thanks
regard
John
Copy link to clipboard
Copied
John,
Taking another stab at it......try the code below.
Set myInDesign = CreateObject("InDesign.Application")
If myInDesign.ActiveDocument.Saved = True Then
Set myFileSystemObject = CreateObject("Scripting.FileSystemObject")
Dim myParentFolder = myFileSystemObject.GetFile(myInDesign).ParentFolder
MsgBox ("The folder containing the active document is: " & myParentFolder)
End If
Regards,
Mike
Copy link to clipboard
Copied
Thank you Mike,
thanks so much.
but still not working.
John

