Vba to save notebook file

mtharnden

Board Regular
Joined
Aug 17, 2011
Messages
114
Hello.
I wrote a code that opens a .txt file in excel that works great for what I am using it for.

What I am doing is exporting data from a webpage in notepad, saving it to my desktop as a .txt file, then the macro opens that file and formats it as needed.

What I would like to know is if there is a way that I can export the data to notebook and have the macro automatically save it as .txt

When exported the notebook file will always have a different name, so is there something that could activate the notebook window regardless the name and save as?
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Sorry I do not know how to place the code into a box but here it is:

It opens the .txt file, separates by comma, makes column 7 as text then copies and pastes it to the macro file. It then exits the .txt file (which is in excel)







Workbooks.OpenText Filename:= _
******* "C:\Documents and Settings\" & Application.UserName & "\Desktop\TEST.txt", Origin:=65001, _
******* StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
******* ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, Comma:=True, _
******* Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1), Array( _
******* 3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 2), Array(8, 1), Array(9, 1), Array(10 _
******* , 1), Array(11, 1), Array(12, 1), Array(13, 1), Array(14, 1), Array(15, 1), Array(16, 1), _
******* Array(17, 1)), TrailingMinusNumbers:=True
***
*** Columns("A:Q").Select
*** Selection.Copy
*** Windows("MacroFile1").Activate
*** Range("A1").Select
*** ActiveSheet.Paste
*** Range("A1").Select
***
*** Windows("TEST.txt").Activate
*** ActiveWindow.Close
*** Windows("MacroFile1").Activate
*
 
Upvote 0

Forum statistics

Threads
1,215,635
Messages
6,125,942
Members
449,275
Latest member
jacob_mcbride

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top