Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

macros

ResolvedVersion 2007

Paul has attended:
Excel Advanced course

Macro's

Designed macro to enable data formatting from a csv file to be maintainined when saved as excel file ... for the specific file name.
Want to be able to enter in a new csv file name which can be saved into excel.
Simon said he had an associate working on a similar request - the solution on this would be most appreciated!

RE: Macro's

Hi Paul,

Thank you for your question.

I believe the code I was referring to was to open a dialogue box to choose a file.

My colleague won't be able to send you the code until Monday.

I hope this is ok.

Regards

Simon

RE: Macro's

Hi Paul

As requested please find below the code that will open a dialog box so that the user can open a file.

I'm not sure what exactly you want to open, or whether you wish to save an already open file. The code below can be adapted to do all of these things let me know if you need any more help

    Dim objFilter As FileDialogFilters
Dim strExcelFile As String

With Application.FileDialog(msoFileDialogOpen)

Set objFilter = .Filters
objFilter.Clear
objFilter.Add "Excel 2003", "*.xls" 'allows for main types of excel workbook
objFilter.Add "Excel 2007", "*.xlsx"
objFilter.Add "Excel 2007 Macro Enabled", "*.xlsm"

.Show

strExcelFile = .SelectedItems(1) 'Picks up path and file name

Application.Workbooks.Open (strExcelFile)


End With


The filters above specify the type of file that the dialog box will display

Regards

Stephen

Tue 8 Dec 2009: Automatically marked as resolved.

Excel tip:

Saving your Excel Spreadsheet as a CSV File

In situations where you need to save your Excel spreadsheet as a CSV file, follow these simple steps.

Click the File tab and click Save As.
Enter a name in the File name field.
Click the drop-down arrow next to the Save as type field to select the file type. Scroll down the list and select CSV (comma delimited) (*.CSV)
Click Save

The data will now be saved to a separate CSV file which can be used in different applications.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.