hobster
asked on
!!!No name problem!!!
Below is a vb function that works:
Private Sub RunPhotoshop()
' variable declaration
Dim App As Object
Dim photoDoc As Object
Dim filename As String
Dim Action As Object
'number of max parameters
Dim param(2) As String
'the current parameter number you're on
Dim paramCounter As Integer
'the number of times run through a loop
Dim loopCounter As Integer
'the character the loop is looking at
Dim currentCharacter As String
Dim parameters As String
Dim ReturnValue As Variant
Dim I As Variant
Dim strText As String
Set App = CreateObject("Photoshop.Ap plication" )
parameters = Command()
paramCounter = 1
For loopCounter = 1 To Len(parameters)
currentCharacter = Mid$(parameters, loopCounter, 1)
If currentCharacter = " " Then
paramCounter = paramCounter + 1
Else
param(paramCounter) = param(paramCounter) & currentCharacter
End If
Next loopCounter
Set photoDoc = App.Open(param(1))
App.PlayAction param(2)
End Sub
The above function is part of an OLE Automation which processes an image file in Photoshop and saves it in a different filename.
The program works if I type something like this from the command prompt:
ole C:\Temp\image.eps export
where ole is the program, C:\Temp\image.eps is the image's path, and export is the Photoshop Action that processes the image.
BUT, if I do something like "ole image.eps export" or "ole \folder1\folder2\image.eps export", I get an error. So it works if I type the full path name but if I type a relative path name, it doesn't work.
Anyone knows how to fix this?
Private Sub RunPhotoshop()
' variable declaration
Dim App As Object
Dim photoDoc As Object
Dim filename As String
Dim Action As Object
'number of max parameters
Dim param(2) As String
'the current parameter number you're on
Dim paramCounter As Integer
'the number of times run through a loop
Dim loopCounter As Integer
'the character the loop is looking at
Dim currentCharacter As String
Dim parameters As String
Dim ReturnValue As Variant
Dim I As Variant
Dim strText As String
Set App = CreateObject("Photoshop.Ap
parameters = Command()
paramCounter = 1
For loopCounter = 1 To Len(parameters)
currentCharacter = Mid$(parameters, loopCounter, 1)
If currentCharacter = " " Then
paramCounter = paramCounter + 1
Else
param(paramCounter) = param(paramCounter) & currentCharacter
End If
Next loopCounter
Set photoDoc = App.Open(param(1))
App.PlayAction param(2)
End Sub
The above function is part of an OLE Automation which processes an image file in Photoshop and saves it in a different filename.
The program works if I type something like this from the command prompt:
ole C:\Temp\image.eps export
where ole is the program, C:\Temp\image.eps is the image's path, and export is the Photoshop Action that processes the image.
BUT, if I do something like "ole image.eps export" or "ole \folder1\folder2\image.eps
Anyone knows how to fix this?
I think you will need to write some code to convert relative pathnames to absolute pathnames. Photoshop will never find "image.eps" (from your sample) because this file is supposed to be in your application directory, not in Photoshop dir.
From VB, you have App.Path that returns the full path from where your app has been initiated.
In your code, you need to parse param(1) to be sure that is an absolute pathname, if has the drive letter an so; if it is not, you will need to change it. I did this before using C, but it can be done in VB.
From VB, you have App.Path that returns the full path from where your app has been initiated.
In your code, you need to parse param(1) to be sure that is an absolute pathname, if has the drive letter an so; if it is not, you will need to change it. I did this before using C, but it can be done in VB.
ASKER
Sorry, can you provide more information? Even pseudocode would be nice. Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I solved the problem using fmismetti's comments.
Check out the CURDIR and CHDIR commands.
M