How to call File Open / Save Window in a Macro

  • Thread starter Thread starter soman
  • Start date Start date
S

soman

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
 
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)
 
Back
Top