VB question

Main area for tech support, questions, suggestions and bug reports.
Forum rules
Please try the FAQs, forum search, and manual before posting.
Please link your account to your registration.
auden
Registered Opus Pro User
Posts: 254
Joined: 26 Jun 2011, 06:01
OS: Windows 10 64-bit
Opus: Directory Opus 10

VB question

Postby auden » 29 Jan 2017, 02:24

I am trying to write a Vb script that will take the tags (keywords) from a file and copy them into a back-up of the file in a different. directory

I have gathered together the keywords in a variable and the name of the file I want to copy to another variable.


The problem comes when I add the instruction to do the actual copy


ClickData.Func.Command.AddLine("SetAttr META newfilename ""tags:" & tagString & """")



newfilename is the name and path of the file I want to write the tags to, and tagString contains the keywords I want to write. They are filled with the correct information

It does not work. I suspect perhaps that because the variable newfilename contains spaces.

Try as I might - and I have tried - I can't find where to put the quote marks to make the command work.

Can one of you VB guru's help?

User avatar
leo
GPSoftware
Posts: 36498
Joined: 07 Nov 2004, 01:30
OS: Windows 10 64-bit
Opus: Directory Opus 12
Location: London, UK
Contact:

Re: VB question

Postby leo » 29 Jan 2017, 07:03

That code will literally insert "newfilename" into the command. If you want to insert the contents of the variable newfilename then you have to do the same thing you're doing with the tagString variable:

Code: Select all

ClickData.Func.Command.AddLine("SetAttr META " & newfilename & " ""tags:" & tagString & """")


You'll also want to put quotes around it, which gives us this:

Code: Select all

ClickData.Func.Command.AddLine("SetAttr META """ & newfilename & """ ""tags:" & tagString & """")


If you still have problems, run this line in the same place and see what it outputs to the script log:

Code: Select all

DOpus.Output "SetAttr META """ & newfilename & """ ""tags:" & tagString & """"


Return to “Help & Support”