#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 37
Default Excel Macros

I'm saving my data as a Text file and use
this command. Unfortunately, it prompts for a use action to
save/replace the file and then prompts again when I close the file.
I'd like code that would not require use intervention.


ActiveWorkbook.SaveAs Filename:="I:\Configs\" & TextStr2,
FileFormat:= xlText, CreateBackup:=False
ActiveWorkbook.Close


Also, I'm trying to search and replace for a string of like this:


****************************************

Unfortunately, it is using this as a wildcard and finds all text. How
can I search for this exact string and only replace this string????




--

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,942
Default Excel Macros

hi
in answer to your first question, you might try this before the same command.

Application.displayalerts = fasle.

this will run off the prompt but be sure to turn alerts back on after the
save.

application.displayalerts = true.

not sure what to do about your second delima. sorry

regards
FSt1

"Chris Premo" wrote:

I'm saving my data as a Text file and use
this command. Unfortunately, it prompts for a use action to
save/replace the file and then prompts again when I close the file.
I'd like code that would not require use intervention.


ActiveWorkbook.SaveAs Filename:="I:\Configs\" & TextStr2,
FileFormat:= xlText, CreateBackup:=False
ActiveWorkbook.Close


Also, I'm trying to search and replace for a string of like this:


****************************************

Unfortunately, it is using this as a wildcard and finds all text. How
can I search for this exact string and only replace this string????




--


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default Excel Macros

FSt1 has provided the answer to the 1st half of your question.

How are you doing the search/replace - manually from the keyboard, or in
code? Are you searching the .txt file created or something else?

"Chris Premo" wrote:

I'm saving my data as a Text file and use
this command. Unfortunately, it prompts for a use action to
save/replace the file and then prompts again when I close the file.
I'd like code that would not require use intervention.


ActiveWorkbook.SaveAs Filename:="I:\Configs\" & TextStr2,
FileFormat:= xlText, CreateBackup:=False
ActiveWorkbook.Close


Also, I'm trying to search and replace for a string of like this:


****************************************

Unfortunately, it is using this as a wildcard and finds all text. How
can I search for this exact string and only replace this string????




--


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Excel Macros

Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:="I:\Configs\" & TextStr2,
FileFormat:= xlText, CreateBackup:=False
ActiveWorkbook.Close
Application.DisplayAlerts = True

To find a wildcard enter the Tilde(~) then the asterisk

i.e. find what: ~*


Gord Dibben MS Excel MVP

On Wed, 31 Dec 2008 10:38:22 -0800, "Chris Premo" wrote:

I'm saving my data as a Text file and use
this command. Unfortunately, it prompts for a use action to
save/replace the file and then prompts again when I close the file.
I'd like code that would not require use intervention.


ActiveWorkbook.SaveAs Filename:="I:\Configs\" & TextStr2,
FileFormat:= xlText, CreateBackup:=False
ActiveWorkbook.Close


Also, I'm trying to search and replace for a string of like this:


****************************************

Unfortunately, it is using this as a wildcard and finds all text. How
can I search for this exact string and only replace this string????


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 37
Default Excel Macros

Gord Dibben wrote:

Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:="I:\Configs\" & TextStr2,
FileFormat:= xlText, CreateBackup:=False
ActiveWorkbook.Close
Application.DisplayAlerts = True

To find a wildcard enter the Tilde(~) then the asterisk

i.e. find what: ~*


Gord Dibben MS Excel MVP

On Wed, 31 Dec 2008 10:38:22 -0800, "Chris Premo"
wrote:

I'm saving my data as a Text file and use
this command. Unfortunately, it prompts for a use action to
save/replace the file and then prompts again when I close the file.
I'd like code that would not require use intervention.


ActiveWorkbook.SaveAs Filename:="I:\Configs\" & TextStr2,

I ended up using this and it worked:


Selection.Replace What:="~*~*", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False



--



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Excel Macros

Good thinnin'


Gord

On Wed, 31 Dec 2008 12:18:52 -0800, "Chris Premo" wrote:

I ended up using this and it worked:


Selection.Replace What:="~*~*", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False


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
Excel 2007 macros - how to merge 5 macros together into one Sue Excel Discussion (Misc queries) 1 April 16th 08 08:36 PM
Macros warning always shows up, even if all macros removed Joe M Excel Discussion (Misc queries) 1 December 20th 07 04:45 AM
Excel Macros Tom Excel Discussion (Misc queries) 2 March 15th 07 09:13 PM
Macros - copying macros from one computer to another TT Excel Discussion (Misc queries) 18 December 14th 06 03:24 AM
Training: More on how to use macros in Excel: Recording Macros ToriT Excel Worksheet Functions 2 February 10th 06 07:05 PM


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

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

About Us

"It's about Microsoft Excel"