• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Excel Save as text question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Excel Save as text question


  • Subject: Re: Excel Save as text question
  • From: Oakley Masten <email@hidden>
  • Date: Wed, 13 May 2009 08:14:02 -0700 (PDT)




From: Stan Cleveland <email@hidden>
To: Oakley Masten <email@hidden>; Users Group AppleScript <email@hidden>
Sent: Thursday, May 7, 2009 5:47:22 PM
Subject: Re: Excel Save as text question
I want to create a new file.
Then populate it with data.
They save it as a txt file.

Also the "with Replacing" doesn't appear to work all the time.
Any help would be appreciated

Oakley, you seem to have two Excel syntax errors. First, you must use the full constant “text Mac file format”, not just “text Mac”. Second, the correct “save” command parameter is “with overwrite”, not “with replacing”.

Make those two changes and see if things don’t work better for you.

HTH,
Stan C.
----------------------------------------------------------------
As always: Thank you Stan for your input.

Using your help, here is what I have gotten to work.  It saves the files just fine and it is the text file I wanted.  But it will not overwrite automatically.
It always opens a dialog box and asks to overwrite.  If I choose "Yes" it overwrites.  If I choose "No" it errors out the script.
I have tried "with overwriting" and "with replacing"  None of them work.
Any more suggestions to make it overwrite automatically?

-- XL 2004 Save As Text Mac Example

--OSX 10.4.11

--This makes 4 files in the desktop folder.

--If you run it again it fails to overwrite


set SourceFolder to path to desktop as alias

MakeAFolder("Excel Text Test", SourceFolder)


tell application "Finder"

set targetFolder to (folder "Excel Text Test" of SourceFolder) as alias

end tell


repeat with x from 1 to 4

set Excel_txt_FileName to "XL_TextFile_" & x & ".txt"

tell application "Microsoft Excel"

activate

make new workbook

delay 2  --just for ease of viewing 

save in ((targetFolder as text) & Excel_txt_FileName) as text Mac file format with overwrite

delay 2  --just for ease of viewing

close active workbook without saving

end tell

end repeat


--#################### Handlers ######################

on MakeAFolder(FolderName, PathToParentFolder)

--Example call --tell me to MakeAFolder("Excel_Copy_Pgs_Printed", SourceFolder)

tell application "Finder"

if not (exists folder FolderName of PathToParentFolder) then

make new folder at PathToParentFolder with properties {name:FolderName}

end if

end tell

end MakeAFolder

--################### END Handler Routines ###############


Thanks

Oakley

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Re: Excel Save as text question (From: Stan Cleveland <email@hidden>)

  • Prev by Date: RE: Script to conditionaly uncheck Hide and show Front Row
  • Next by Date: Re: Excel Save as text question
  • Previous by thread: Re: Excel Save as text question
  • Next by thread: re:Excel Save as text question
  • Index(es):
    • Date
    • Thread