Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Can you save an external macro?

Is it possible to save a macro all by itself, so that it acts sort of
like a batch file?

I want to have two things in my working directory, a text file and this
standalone macro (or something to the likes of it). I want to be able
to click once and have the macro (or whatever) import the text file
into Excel, format the file to my liking and save it under the filename
of the original text file with the extension .xls, of course.

Can I do all this with a macro? And, back to the original question, can
I actually have a standalone macro that will let me do this?

Thanks


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Can you save an external macro?

Macros in excel live in workbooks. So just create a "importmytextfile.xls"
workbook that contains your macro.

Put your code in a macro called "auto_open" in a general module.

Then right before your macro ends, add

thisworkbook.close savechanges:=false

(Make sure you save the macro before running tests--else it won't get saved.)

Then starting the excel file will run your macro and close the workbook when
it's done.

genEus wrote:

Is it possible to save a macro all by itself, so that it acts sort of
like a batch file?

I want to have two things in my working directory, a text file and this
standalone macro (or something to the likes of it). I want to be able
to click once and have the macro (or whatever) import the text file
into Excel, format the file to my liking and save it under the filename
of the original text file with the extension .xls, of course.

Can I do all this with a macro? And, back to the original question, can
I actually have a standalone macro that will let me do this?

Thanks

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Can you save an external macro?

Is it possible ....? Sort of.

Take a look at VBS. Here's an example. Save it in a standard text file with
a .VBS extention.
This one creates an Excel object, opens a workbook, sets a value, runs a VBA
routine, then tidies up and closes down.

Set xlObj = CreateObject("Excel.application")
xlObj.Workbooks.Open "C:\Byg\textfile\TextFileReformat.xls"
xlObj.Range("NoOfCharsPerLine").Value = 50
xlObj.Run "ReadFromTextFile"
xlObj.ActiveWorkbook.Saved = True
xlObj.ActiveWindow.Close
xlObj.Quit


--

Regards
Andy Wiggins
www.BygSoftware.com
Home of "Save and BackUp",
"The Excel Auditor" and "Byg Tools for VBA"


"genEus" wrote in message
...
Is it possible to save a macro all by itself, so that it acts sort of
like a batch file?

I want to have two things in my working directory, a text file and this
standalone macro (or something to the likes of it). I want to be able
to click once and have the macro (or whatever) import the text file
into Excel, format the file to my liking and save it under the filename
of the original text file with the extension .xls, of course.

Can I do all this with a macro? And, back to the original question, can
I actually have a standalone macro that will let me do this?

Thanks


---
Message posted from http://www.ExcelForum.com/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I save external data in Excel? Ankur Bhatnagar Excel Discussion (Misc queries) 0 March 5th 10 11:30 AM
Save External Link Values kmccann Excel Discussion (Misc queries) 0 April 26th 06 11:30 AM
Cannot save external links? KRAMER Excel Worksheet Functions 0 June 6th 05 04:56 AM
Save External Link Values Stephane Excel Discussion (Misc queries) 0 January 3rd 05 11:01 AM
auto save-as from external inputs motionS Excel Programming 0 October 1st 03 04:36 PM


All times are GMT +1. The time now is 10:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"