 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
F. Milibricz Guest
|
Posted: Sun May 13, 2007 5:16 am Post subject: Saving text as Excel file |
|
|
I am opening a tab-delimited text file in Excel, formatting the contents and
want to save the file in Excel (.xls) format. My problem is that when I
save the file, I am always prompted with the following messages:
Prompt 1: Do you want to save the changes made to <filename>?
- I click Yes
Prompt 2: The Save As dialog opens and the "Save as type" drop down box
shows "Text (Tab delimited)(*.txt)"
and I must manually change it to .xls file type.
How can I force the "Yes" responce to prompt #1 (I always want to save the
changes), and how can I have it set the file type to Excel .xls format
without any user prompts? Any help is appreciated.
Thanks! |
|
| Back to top |
|
 |
Oliver Townshend Guest
|
Posted: Sun May 13, 2007 5:52 am Post subject: Re: Saving text as Excel file |
|
|
| Quote: | How can I force the "Yes" responce to prompt #1 (I always want to save the
changes), and how can I have it set the file type to Excel .xls format
without any user prompts? Any help is appreciated.
|
Try using Application.GetSaveAsFilename, and then do a Workbook.Saveas
Oliver Townshend |
|
| Back to top |
|
 |
F. Milibricz Guest
|
Posted: Sun May 13, 2007 7:30 am Post subject: Re: Saving text as Excel file |
|
|
Oliver,
Thanks for your reply. However, the result is the same. I am still
receiving both prompts.
Milibricz
"Oliver Townshend" <oliveratcodelegaldotcomdotau> wrote in message
news:4646615a$1 (AT) newsgroups (DOT) borland.com...
| Quote: | How can I force the "Yes" responce to prompt #1 (I always want to save
the changes), and how can I have it set the file type to Excel .xls
format without any user prompts? Any help is appreciated.
Try using Application.GetSaveAsFilename, and then do a Workbook.Saveas
Oliver Townshend |
|
|
| Back to top |
|
 |
Mike Shkolnik Guest
|
Posted: Sun May 13, 2007 5:42 pm Post subject: Re: Saving text as Excel file |
|
|
Just set the DisplayAlerts for ExcelApplication to False:
yourExcelApplication.DisplayAlerts := False;
--
With best regards, Mike Shkolnik
Scalabium Software
http://www.scalabium.com
mshkolnik (AT) scalabium (DOT) com
"F. Milibricz" <fmilibricz (AT) revenuecorp (DOT) com> wrote in message
news:464658d4 (AT) newsgroups (DOT) borland.com...
| Quote: | I am opening a tab-delimited text file in Excel, formatting the contents
and
want to save the file in Excel (.xls) format. My problem is that when I
save the file, I am always prompted with the following messages:
Prompt 1: Do you want to save the changes made to <filename>?
- I click Yes
Prompt 2: The Save As dialog opens and the "Save as type" drop down box
shows "Text (Tab delimited)(*.txt)"
and I must manually change it to .xls file type.
How can I force the "Yes" responce to prompt #1 (I always want to save the
changes), and how can I have it set the file type to Excel .xls format
without any user prompts? Any help is appreciated.
Thanks!
|
|
|
| Back to top |
|
 |
F. Milibricz Guest
|
Posted: Sun May 13, 2007 5:46 pm Post subject: Re: Saving text as Excel file |
|
|
I thought that setting DisplayAlerts to False discards changes (ie. it
responds No to the prompt). I need changes to be saved. Any idea how this
can be done?
Thanks.
Milibricz
"Mike Shkolnik" <mshkolnik2002 (AT) ukr (DOT) net> wrote in message
news:464707b8 (AT) newsgroups (DOT) borland.com...
| Quote: | Just set the DisplayAlerts for ExcelApplication to False:
yourExcelApplication.DisplayAlerts := False;
--
With best regards, Mike Shkolnik
Scalabium Software
http://www.scalabium.com
mshkolnik (AT) scalabium (DOT) com
"F. Milibricz" <fmilibricz (AT) revenuecorp (DOT) com> wrote in message
news:464658d4 (AT) newsgroups (DOT) borland.com...
I am opening a tab-delimited text file in Excel, formatting the contents
and
want to save the file in Excel (.xls) format. My problem is that when I
save the file, I am always prompted with the following messages:
Prompt 1: Do you want to save the changes made to <filename>?
- I click Yes
Prompt 2: The Save As dialog opens and the "Save as type" drop down box
shows "Text (Tab delimited)(*.txt)"
and I must manually change it to .xls file type.
How can I force the "Yes" responce to prompt #1 (I always want to save
the
changes), and how can I have it set the file type to Excel .xls format
without any user prompts? Any help is appreciated.
Thanks!
|
|
|
| Back to top |
|
 |
Mike Shkolnik Guest
|
Posted: Sun May 13, 2007 8:57 pm Post subject: Re: Saving text as Excel file |
|
|
You need set the DisplayAlerts to False and call the SaveAs method:
yourExcelApplication.DisplayAlerts := False;
yourWorkBook.SaveAs(yourXLSFileName)
--
With best regards, Mike Shkolnik
Scalabium Software
http://www.scalabium.com
mshkolnik (AT) scalabium (DOT) com
"F. Milibricz" <fmilibricz (AT) revenuecorp (DOT) com> wrote in message
news:464708a6$1 (AT) newsgroups (DOT) borland.com...
| Quote: | I thought that setting DisplayAlerts to False discards changes (ie. it
responds No to the prompt). I need changes to be saved. Any idea how
this
can be done?
Thanks.
Milibricz
"Mike Shkolnik" <mshkolnik2002 (AT) ukr (DOT) net> wrote in message
news:464707b8 (AT) newsgroups (DOT) borland.com...
Just set the DisplayAlerts for ExcelApplication to False:
yourExcelApplication.DisplayAlerts := False;
--
With best regards, Mike Shkolnik
Scalabium Software
http://www.scalabium.com
mshkolnik (AT) scalabium (DOT) com
"F. Milibricz" <fmilibricz (AT) revenuecorp (DOT) com> wrote in message
news:464658d4 (AT) newsgroups (DOT) borland.com...
I am opening a tab-delimited text file in Excel, formatting the
contents
and
want to save the file in Excel (.xls) format. My problem is that when
I
save the file, I am always prompted with the following messages:
Prompt 1: Do you want to save the changes made to <filename>?
- I click Yes
Prompt 2: The Save As dialog opens and the "Save as type" drop down
box
shows "Text (Tab delimited)(*.txt)"
and I must manually change it to .xls file type.
How can I force the "Yes" responce to prompt #1 (I always want to save
the
changes), and how can I have it set the file type to Excel .xls format
without any user prompts? Any help is appreciated.
Thanks!
|
|
|
| Back to top |
|
 |
F. Milibricz Guest
|
Posted: Tue May 15, 2007 5:29 am Post subject: Re: Saving text as Excel file |
|
|
Mike, thank you for your help. It is appreciated. I no longer receive the
prompt, but the formatting changes I made are now lost. Here is my code.
Please help if you have an idea of where my error(s) are being made:
// open Excel and import the tab-delimited text file.
OleApplication0 := CreateOleObject('Excel.Application');
OleApplication0.Visible := False;
OleWorkBook0 := OleApplication0.Workbooks.Open(fname2); // fname2 is a
string containin the .txt file name
// Format the column widths
ColumnRange := OleApplication0.Workbooks[1].WorkSheets[1].Columns;
// Insert the 'No.' column
ColumnRange.Columns[1].Insert;
OleApplication0.Range['A1'] := 'No.';
// Delete unwanted columns and rearrange others
ColumnRange.Columns[3].Delete;
ColumnRange.Columns[4].Delete;
ColumnRange.Columns[4].Cut;
ColumnRange.Columns[8].Insert;
ColumnRange.Columns[10].Delete;
ColumnRange.Columns[10].Delete;
ColumnRange.Columns[10].Delete;
// Change column headings to bold font style
OleApplication0.Range['A1:Z1'].Font.Bold := True;
OleApplication0.Range['A1:Z1'].Interior.ColorIndex := 37; // 37 = Pale
Blue
// Adjust widths of columns
ColumnRange.Columns[1].ColumnWidth := StrToInt(Edit1.Text);
ColumnRange.Columns[2].ColumnWidth := StrToInt(Edit2.Text);
ColumnRange.Columns[3].ColumnWidth := StrToInt(Edit3.Text);
...
...
...
// Save and close the workbook
OleApplication0.DisplayAlerts := False;
OleApplication0.Workbooks[1].SaveAs(fname2);
OleApplication0.Quit;
OleApplication0 := unassigned;
The resulting saved file contains all the changes, except the cell
formatting (i.e. bold text headings, shading of cells, column widths) is
lost.
Thanks again for your help.
Milibricz
"Mike Shkolnik" <mshkolnik2002 (AT) ukr (DOT) net> wrote in message
news:46473588 (AT) newsgroups (DOT) borland.com...
| Quote: | You need set the DisplayAlerts to False and call the SaveAs method:
yourExcelApplication.DisplayAlerts := False;
yourWorkBook.SaveAs(yourXLSFileName)
--
With best regards, Mike Shkolnik
Scalabium Software
http://www.scalabium.com
mshkolnik (AT) scalabium (DOT) com
"F. Milibricz" <fmilibricz (AT) revenuecorp (DOT) com> wrote in message
news:464708a6$1 (AT) newsgroups (DOT) borland.com...
I thought that setting DisplayAlerts to False discards changes (ie. it
responds No to the prompt). I need changes to be saved. Any idea how
this
can be done?
Thanks.
Milibricz
"Mike Shkolnik" <mshkolnik2002 (AT) ukr (DOT) net> wrote in message
news:464707b8 (AT) newsgroups (DOT) borland.com...
Just set the DisplayAlerts for ExcelApplication to False:
yourExcelApplication.DisplayAlerts := False;
--
With best regards, Mike Shkolnik
Scalabium Software
http://www.scalabium.com
mshkolnik (AT) scalabium (DOT) com
"F. Milibricz" <fmilibricz (AT) revenuecorp (DOT) com> wrote in message
news:464658d4 (AT) newsgroups (DOT) borland.com...
I am opening a tab-delimited text file in Excel, formatting the
contents
and
want to save the file in Excel (.xls) format. My problem is that when
I
save the file, I am always prompted with the following messages:
Prompt 1: Do you want to save the changes made to <filename>?
- I click Yes
Prompt 2: The Save As dialog opens and the "Save as type" drop down
box
shows "Text (Tab delimited)(*.txt)"
and I must manually change it to .xls file type.
How can I force the "Yes" responce to prompt #1 (I always want to save
the
changes), and how can I have it set the file type to Excel .xls format
without any user prompts? Any help is appreciated.
Thanks!
|
|
|
| Back to top |
|
 |
F. Milibricz Guest
|
Posted: Tue May 15, 2007 10:17 pm Post subject: Re: Saving text as Excel file |
|
|
I've found that setting DisplayAlerts to False and calling the SaveAs method
will not change the "Save as type" drop-down box to Excel format from
Tab-Delimited format. Does anyone know how this may be done? I believe it
is the only thing preventing me from finishing this work!
TIA
Milibricz
"Mike Shkolnik" <mshkolnik2002 (AT) ukr (DOT) net> wrote in message
news:46473588 (AT) newsgroups (DOT) borland.com...
| Quote: | You need set the DisplayAlerts to False and call the SaveAs method:
yourExcelApplication.DisplayAlerts := False;
yourWorkBook.SaveAs(yourXLSFileName)
--
With best regards, Mike Shkolnik
Scalabium Software
http://www.scalabium.com
mshkolnik (AT) scalabium (DOT) com
"F. Milibricz" <fmilibricz (AT) revenuecorp (DOT) com> wrote in message
news:464708a6$1 (AT) newsgroups (DOT) borland.com...
I thought that setting DisplayAlerts to False discards changes (ie. it
responds No to the prompt). I need changes to be saved. Any idea how
this
can be done?
Thanks.
Milibricz
"Mike Shkolnik" <mshkolnik2002 (AT) ukr (DOT) net> wrote in message
news:464707b8 (AT) newsgroups (DOT) borland.com...
Just set the DisplayAlerts for ExcelApplication to False:
yourExcelApplication.DisplayAlerts := False;
--
With best regards, Mike Shkolnik
Scalabium Software
http://www.scalabium.com
mshkolnik (AT) scalabium (DOT) com
"F. Milibricz" <fmilibricz (AT) revenuecorp (DOT) com> wrote in message
news:464658d4 (AT) newsgroups (DOT) borland.com...
I am opening a tab-delimited text file in Excel, formatting the
contents
and
want to save the file in Excel (.xls) format. My problem is that when
I
save the file, I am always prompted with the following messages:
Prompt 1: Do you want to save the changes made to <filename>?
- I click Yes
Prompt 2: The Save As dialog opens and the "Save as type" drop down
box
shows "Text (Tab delimited)(*.txt)"
and I must manually change it to .xls file type.
How can I force the "Yes" responce to prompt #1 (I always want to save
the
changes), and how can I have it set the file type to Excel .xls format
without any user prompts? Any help is appreciated.
Thanks!
|
|
|
| Back to top |
|
 |
Mike Shkolnik Guest
|
Posted: Wed May 16, 2007 1:50 am Post subject: Re: Saving text as Excel file |
|
|
Just add the parameter with file type:
OleApplication0.Workbooks[1]..SaveAs(fname2, xlExcel7);
where
const
xlExcel7 = $00000027;
--
With best regards, Mike Shkolnik
Scalabium Software
http://www.scalabium.com
mshkolnik (AT) scalabium (DOT) com
"F. Milibricz" <fmilibricz (AT) revenuecorp (DOT) com> wrote in message
news:4649eb2c$1 (AT) newsgroups (DOT) borland.com...
| Quote: | I've found that setting DisplayAlerts to False and calling the SaveAs
method
will not change the "Save as type" drop-down box to Excel format from
Tab-Delimited format. Does anyone know how this may be done? I believe
it
is the only thing preventing me from finishing this work!
TIA
Milibricz
"Mike Shkolnik" <mshkolnik2002 (AT) ukr (DOT) net> wrote in message
news:46473588 (AT) newsgroups (DOT) borland.com...
You need set the DisplayAlerts to False and call the SaveAs method:
yourExcelApplication.DisplayAlerts := False;
yourWorkBook.SaveAs(yourXLSFileName)
--
With best regards, Mike Shkolnik
Scalabium Software
http://www.scalabium.com
mshkolnik (AT) scalabium (DOT) com
"F. Milibricz" <fmilibricz (AT) revenuecorp (DOT) com> wrote in message
news:464708a6$1 (AT) newsgroups (DOT) borland.com...
I thought that setting DisplayAlerts to False discards changes (ie. it
responds No to the prompt). I need changes to be saved. Any idea how
this
can be done?
Thanks.
Milibricz
"Mike Shkolnik" <mshkolnik2002 (AT) ukr (DOT) net> wrote in message
news:464707b8 (AT) newsgroups (DOT) borland.com...
Just set the DisplayAlerts for ExcelApplication to False:
yourExcelApplication.DisplayAlerts := False;
--
With best regards, Mike Shkolnik
Scalabium Software
http://www.scalabium.com
mshkolnik (AT) scalabium (DOT) com
"F. Milibricz" <fmilibricz (AT) revenuecorp (DOT) com> wrote in message
news:464658d4 (AT) newsgroups (DOT) borland.com...
I am opening a tab-delimited text file in Excel, formatting the
contents
and
want to save the file in Excel (.xls) format. My problem is that
when
I
save the file, I am always prompted with the following messages:
Prompt 1: Do you want to save the changes made to <filename>?
- I click Yes
Prompt 2: The Save As dialog opens and the "Save as type" drop down
box
shows "Text (Tab delimited)(*.txt)"
and I must manually change it to .xls file type.
How can I force the "Yes" responce to prompt #1 (I always want to
save
the
changes), and how can I have it set the file type to Excel .xls
format
without any user prompts? Any help is appreciated.
Thanks!
|
|
|
| Back to top |
|
 |
F. Milibricz Guest
|
Posted: Wed May 16, 2007 2:21 am Post subject: Re: Saving text as Excel file |
|
|
Mike...THANKS!!!! It works!!.
....you rock!
Milibricz
"Mike Shkolnik" <mshkolnik2002 (AT) ukr (DOT) net> wrote in message
news:464a1d1c (AT) newsgroups (DOT) borland.com...
| Quote: | Just add the parameter with file type:
OleApplication0.Workbooks[1]..SaveAs(fname2, xlExcel7);
where
const
xlExcel7 = $00000027;
--
With best regards, Mike Shkolnik
Scalabium Software
http://www.scalabium.com
mshkolnik (AT) scalabium (DOT) com
"F. Milibricz" <fmilibricz (AT) revenuecorp (DOT) com> wrote in message
news:4649eb2c$1 (AT) newsgroups (DOT) borland.com...
I've found that setting DisplayAlerts to False and calling the SaveAs
method
will not change the "Save as type" drop-down box to Excel format from
Tab-Delimited format. Does anyone know how this may be done? I believe
it
is the only thing preventing me from finishing this work!
TIA
Milibricz
"Mike Shkolnik" <mshkolnik2002 (AT) ukr (DOT) net> wrote in message
news:46473588 (AT) newsgroups (DOT) borland.com...
You need set the DisplayAlerts to False and call the SaveAs method:
yourExcelApplication.DisplayAlerts := False;
yourWorkBook.SaveAs(yourXLSFileName)
--
With best regards, Mike Shkolnik
Scalabium Software
http://www.scalabium.com
mshkolnik (AT) scalabium (DOT) com
"F. Milibricz" <fmilibricz (AT) revenuecorp (DOT) com> wrote in message
news:464708a6$1 (AT) newsgroups (DOT) borland.com...
I thought that setting DisplayAlerts to False discards changes (ie. it
responds No to the prompt). I need changes to be saved. Any idea how
this
can be done?
Thanks.
Milibricz
"Mike Shkolnik" <mshkolnik2002 (AT) ukr (DOT) net> wrote in message
news:464707b8 (AT) newsgroups (DOT) borland.com...
Just set the DisplayAlerts for ExcelApplication to False:
yourExcelApplication.DisplayAlerts := False;
--
With best regards, Mike Shkolnik
Scalabium Software
http://www.scalabium.com
mshkolnik (AT) scalabium (DOT) com
"F. Milibricz" <fmilibricz (AT) revenuecorp (DOT) com> wrote in message
news:464658d4 (AT) newsgroups (DOT) borland.com...
I am opening a tab-delimited text file in Excel, formatting the
contents
and
want to save the file in Excel (.xls) format. My problem is that
when
I
save the file, I am always prompted with the following messages:
Prompt 1: Do you want to save the changes made to <filename>?
- I click Yes
Prompt 2: The Save As dialog opens and the "Save as type" drop
down
box
shows "Text (Tab delimited)(*.txt)"
and I must manually change it to .xls file type.
How can I force the "Yes" responce to prompt #1 (I always want to
save
the
changes), and how can I have it set the file type to Excel .xls
format
without any user prompts? Any help is appreciated.
Thanks!
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|