ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Excel Macros (https://www.excelbanter.com/excel-discussion-misc-queries/215036-excel-macros.html)

Chris Premo

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????




--


FSt1

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????




--



JLatham

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????




--



Gord Dibben

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????



Chris Premo

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



--


Gord Dibben

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




All times are GMT +1. The time now is 07:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com