Sign in to follow this  
uncle_rico

I don't understand this VBA error I'm getting.

Recommended Posts

I'm just trying to write a function for an Access module that concatenates two strings together, and then uses the result as the pathname for a shell command. Here's what it looks like now:
Function ConvertWav2AT3()

Dim prjPath As String
Set prjPath = Environ$("PROJECT_PATH")

Dim shellPath As String
Set shellPath = "C:\program.exe -e _
      " & prjPath & "\src.foo c:\dest.foo"

Shell(shellPath, 1)

End Function
So you can see that "program.exe" takes on various arguments, including a destination file name and a source filename. The source file name depends on the person's PROJECT_PATH environment variable, and so I can't just set it here. I have to "concatenate" it into the source path. After typing in the Shell(shellPath, 1) function, I get an error that says:
Compile Error:
Expected: =
I have no idea what it's asking for. I though maybe it needed me to named the arguments, so I tried Shell(pathname:=shellPath, windowstyle:=1) and I still get the same error. Any ideas?

Share this post


Link to post
Share on other sites
Of course, now when I run the module, I get another error I don't understand:
Compiler error:
Object required

When I click "Ok", the "prjPath =" part of the Set statement is highlighted as though I've clicked and dragged the mouse over it. Also, the very first line of the code (with the function name) is highlighted in yellow.

I want to learn how to do this, but it's frustrating to run into these errors whenever I try to do the simplest thing.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this