Renaming code won't accept spaces

This bit of code fails when the user enters a space to be included as part of a new file name. Or said another way, it's as if a space is an illegal character...yet renaming using the built in methods accepts space characters as expected.

The code asks for the users input ("Enter Property ID"), and renames the file using the that input ,and the exisiting file name....then selects the next file.

@set id = {dlgstring|Enter Property ID}
@set id="word1word2"
Rename PATTERN * TO {$id}_*
Select NEXT

What have I missed?

Thanks, Greg

You forgot the quotes.

Rename PATTERN * TO "{$id}_*"

Not sure what you're trying to achieve with the line:

@set id="word1word2"

But it shouldn't be there as far as I can see.

Thanks so much steve...(that word1word1 was garbage I used to test)

How are you on VBscript? Below is another apporach to do the same thing I'd stuck onto a button, but I'm missing something...I'm new to Dopus coding.

@script vbscript
Option Explicit
Function Rename_GetNewName2(strFileName, strFilePath, fIsFolder, strOldName, strNewName)

Rename_GetNewName2 =inputbox("Enter ID") "_" & strFileName
End Function

Much appreciated, Greg

The following script can be placed in a button: [code]Rename PATTERN * TO *
@script vbscript
Option Explicit

Dim strTmpInput

Function Rename_GetNewName2(strFileName, strFilePath, fIsFolder, strOldName, strNewName)
strTmpInput = InputBox ( "Enter ID", "Property ID Rename")
If strTmpInput = "" Then
Exit Function
End If
Rename_GetNewName2 = strTmpInput & " _ " & strFileName
End Function
[/code]

Works a treat. Thanks Steve.

Is there any resource/reference material you aware of that explains how DOpus functions with VBA...for example, can I start an instance of Access?...and then pass variables/arguments between Dopus and Access so the user could choose from a list of allowable IDs...say using a ususal Combo or List control linked to an Access table?

If so, then once I konow DoOpus and Access can talk to each other, I'm fine with the coding.

Thnaks again for helping me.

Greg

I'm not aware of any specific resources explaining Opus and Access. Having said that, I'm sure you can use the Opus renaming system to manipulate data in an Access database. No idea how though. :slight_smile:

You should be able to talk to Access from VBScript using code like this:

Dim objAccess Set objAccess = CreateObject("Access.Application")
(I haven't tested that as I don't have Access installed.)

You can then call methods on objAccess like you can within Access itself.

(Note that VBScript has a slightly different syntax to the VBA used within Office.)

You may find it easier to start with a standalone .vbs script file which you can edit and run outside of Opus. That way it'll be much less cumbersome to experiment with talking to Access from VBScript. Once you get that working you can put it into your Opus rename script.