ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to call File Open / Save Window in a Macro (https://www.excelbanter.com/excel-programming/289419-how-call-file-open-save-window-macro.html)

[email protected]

How to call File Open / Save Window in a Macro
 
I would appreciate if anybody give me a solution on...

I have a macro that opens a text file into Excel 2000
thru. text import wizard.
I want to fine tune it... like when I run the macro
it should popup the "File Open" window and allow to select
the text file to import from any drive/folder.

Similarly after import process is over the macro should
popup the window "Save as", so as to save at desired
drive/folder.

How to do this???

Thanks in Adv
Shanks


Bob Phillips[_6_]

How to call File Open / Save Window in a Macro
 
Hi Shanks,


Dim sFile
sFile = Application.GetOpenFilename("Text Files (*.txt), *.txt")
If sFile < False Then
Workbooks.OpenText Filename:=sFile, _
Origin:=xlWindows, _
StartRow:=1, _
DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(10, 1), _
Array(21, 1), Array(52, 1), _
Array(62, 1), Array(105, 1), _
Array(117, 1), Array(135, 1),
Array(157, 1))

'do your bit
sFile = Application.GetSaveAsFilename(, "Text Files (*.txt), *.txt")
If sFile < False Then
ActiveWorkbook.SaveAs Filename:=sFile
End If
End If



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

" wrote in message
...
I would appreciate if anybody give me a solution on...

I have a macro that opens a text file into Excel 2000
thru. text import wizard.
I want to fine tune it... like when I run the macro
it should popup the "File Open" window and allow to select
the text file to import from any drive/folder.

Similarly after import process is over the macro should
popup the window "Save as", so as to save at desired
drive/folder.

How to do this???

Thanks in Adv
Shanks





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

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