Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to define my file parent in vbs

Contributor ,
May 23, 2019 May 23, 2019

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

TOPICS
Scripting
443
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 23, 2019 May 23, 2019

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
May 27, 2019 May 27, 2019

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 27, 2019 May 27, 2019

thank you Mike,

not working.

error on line 5

the myActiveDocument is not found.

thanks

regard

John

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
May 27, 2019 May 27, 2019

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 27, 2019 May 27, 2019
LATEST

Thank you Mike,

thanks so much.

but still not working.

John

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines