ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Naming A Worksheet (https://www.excelbanter.com/excel-programming/376065-naming-worksheet.html)

Charles A. Lackman

Naming A Worksheet
 
Hello,

In VB.net I am creating a CSV File.

With Excel
..SheetsInNewWorkbook = 1
..Workbooks.Add(1)
..Worksheets().Select()

(Create Columns and Rows)

When I save the file.

..Application.DisplayAlerts = False
..ActiveWorkbook().SaveAs("C:\MyCSV.csv",
..ActiveWorkbook.FileFormat.xlCSVWindows)
..ActiveWorkbook.Close()

The worksheet is named MyCSV, I want the worksheet to have a different name
than the saved file.

Any assistance will be greatly appreciated.

Thanks,

Chuck



Dave Peterson

Naming A Worksheet
 
You can change the name of the worksheet. But I wouldn't bother. The next time
you open the .CSV file, excel will use what it wants for the worksheet
name--usually the name of that .csv file (without the .csv file extension).

So it's not your saving that's the problem. It's the reopening.

Since .csv files are plain old text, there's nothing you can do with the file
itself. You can always rename the worksheet after the file is reopened.


"Charles A. Lackman" wrote:

Hello,

In VB.net I am creating a CSV File.

With Excel
.SheetsInNewWorkbook = 1
.Workbooks.Add(1)
.Worksheets().Select()

(Create Columns and Rows)

When I save the file.

.Application.DisplayAlerts = False
.ActiveWorkbook().SaveAs("C:\MyCSV.csv",
.ActiveWorkbook.FileFormat.xlCSVWindows)
.ActiveWorkbook.Close()

The worksheet is named MyCSV, I want the worksheet to have a different name
than the saved file.

Any assistance will be greatly appreciated.

Thanks,

Chuck


--

Dave Peterson


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

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