Sign in to follow this  
Followers 0
NSearch

FileExists Problem

12 posts in this topic

For some reason my FileExists statement will not work. Can anyone see what I am doing wrong?

Statement to save excel file (enters data in save as box and clicks enter).

If $domestic <> "D" then

Send("C:\"&$short_name&" International Detail "&$remit&"")

Send("{ENTER}")

EndIf

Statement to close excel once file has saved:

If $domestic <> "D" then

While $flag = 0

If FileExists("C:\"&$short_name&" International Detail "&$remit&".xls") Then

ProcessClose("excel.exe")

ExitLoop

EndIf

WEnd

EndIf

Share this post


Link to post
Share on other sites



Share this post


Link to post
Share on other sites

yes, it is created and saved. I can not understand why it is not being recognized

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

u gonna need to but a couple of debug points in your code to see what value $Domestic $Flag are returning.

put a messagebox(0,"Value of $Domestic + $Flag",$Domestic&" "&$Flag)

before both your save and close excel If statemnts. Other than that we need a bit more code to see what you actually defining in those variables.

HardCopy

Edited by HardCopy

Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad

Share this post


Link to post
Share on other sites

I have done this, and everything comes back the way that it should be before saving, and closing. Both have the same value, but for some reason I can not get it to recognize the file using fileexists.

Share this post


Link to post
Share on other sites

Try putting this line in there:

InputBox('Test', 'FilePath', "C:\"&$short_name&" International Detail "&$remit&".xls")

And if it looks normal, copy from the input box, and paste into your Start>Run dialog, and try to execute like that. If that works fine, then I'll be stumped.

Share this post


Link to post
Share on other sites

I am getting a "block". Looks to be a carriage return right before .xls

Am I constructing my string wrong?

FileExists("C:\"&$short_name&" International Detail "&$remit&".xls")

Share this post


Link to post
Share on other sites

If $domestic <> "D" then

Send("C:\"&$short_name&" International Detail "&$remit&"")

Send("{ENTER}")

EndIf

Well u tagging an extra null on the end here!! dunno if that would kill it.

change "" to ".xls" try that


Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad

Share this post


Link to post
Share on other sites

If $domestic <> "D" then

Send("C:\"&$short_name&" International Detail "&$remit&"")

Send("{ENTER}")

EndIf

Well u tagging an extra null on the end here!! dunno if that would kill it.

change "" to ".xls" try that

<{POST_SNAPBACK}>

try putting a space on either side of each of your &'s... if nothing else it will help readability. i know in vbs it doesn't like it when &'s are appended to variable names.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

I see what is happening. I am drawing in a carriage return when grabbing the remit number from a file. Is there a string command to strip a string of carriage returns?

Share this post


Link to post
Share on other sites

StringStripCR ( "string" )

Got it. Thanks everyone from your help!!!

Share this post


Link to post
Share on other sites

Just in case.. that will only strip carriage returns (ascii 13) sometimes you might have a line feed (ascii 10) on there too, in that case, try StringStripWS (whitespace).

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  
Followers 0