Solved

!!!No name problem!!!

Posted on 1998-10-14
5
226 Views
Last Modified: 2011-09-20
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.Application")
     
   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?
0
Comment
Question by:hobster
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 12

Expert Comment

by:mark2150
ID: 1439976
Obviously it all depends on what directory you're in when you fire the code. Normally if you're debugging a VB program your in some dir off C:\Program Files\Visual Basic. If the image is in C:\Temp then if you don't spec a full path you're child isn't going to find the file.

Check out the CURDIR and CHDIR commands.

M

0
 
LVL 1

Expert Comment

by:fmismetti
ID: 1439977
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.


0
 
LVL 2

Author Comment

by:hobster
ID: 1439978
Sorry, can you provide more information? Even pseudocode would be nice. Thanks.
0
 

Accepted Solution

by:
mnord earned 10 total points
ID: 1439979
You can use the App.Path and Dir statements as others have referenced here (from the comments) but.....you can also add the paths where your image files and application files are located in your Path statement in your autoexec.bat file.   This is a really "cheesy" fix but it will work especially if you do not feel like making all those code changes.

An example line from your autoexec.bat file:

Path=c:;c:\windows;c:\windows\command;c:\images;c:\adobe


Hope this helps.  This is a quick and dirty fix that I have used for VB5 and Access.

0
 
LVL 2

Author Comment

by:hobster
ID: 1439980
I solved the problem using fmismetti's comments.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MsgBox 4 76
VB6 ListBox Question 4 63
transition to visual .net from vb6 5 81
Assign a value in Excel V-Basic 3 38
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question