473,753 Members | 5,849 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

save the file in Excel format

18 New Member
Hi,

The below code will allow the user to open the Save As dialog box,

Now my question is : after the user specify the file name and the path, how can I modify the below code in order to save the file in Excel format when the user click on the Save button

What I need is to use the file name which was specified by the user in the dialog box , and then create an Excel file using the same name & path and the new excel file should not contain any data just empty worksheet


Expand|Select|Wrap|Line Numbers
  1. Private Sub Command16_Click()
  2.  
  3.     Dim fd As FileDialog
  4.     Dim vrtSelectedItem As Variant
  5.  
  6.     Set fd = Application.FileDialog(msoFileDialogSaveAs)
  7.  
  8.       With fd
  9.  
  10.         If .Show = -1 Then
  11.  
  12.             For Each vrtSelectedItem In .SelectedItems
  13.  
  14.                 MsgBox "The path is: " & vrtSelectedItem
  15.  
  16.             Next vrtSelectedItem
  17.  
  18.         Else
  19.         End If
  20.     End With
  21.  
  22.     Set fd = Nothing
  23.  
  24. End Sub
Jan 26 '10 #1
4 3301
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi, and Welcome to Bytes!

It is not clear from your question what you are doing with your file selections. If you are using the Office file dialog in multi-select mode you must be expecting users to select one or more existing file names from a file directory in a folder somewhere. If that is the case, saving these files in Excel format will depend on what the type of the file is that your users have selected - and you don't tell us that at all.

If what you really mean is that you are asking users to specify a filename to save some existing data from Access, say, in Excel format then that is quite a different matter - you would not need the file dialog in multi-select mode for that. The file dialog would be selecting the destination folder, not multiple instances of files I would have thought.

Without clarification of what you really want to happen on what data it is difficult to advise you further. In Access there is the DoCmd.TransferS preadsheet method which can output Access queries in Excel format to a given path and filename but I can't tell from your question if this is what you need or not.

If you are working in Excel itself you can add a new blank workbook using the .Add method of the Workbooks collection, then use the .SaveAs method to save the blank workbook under whatever name is required. If you want to have multiple blank files you would do this in some kind of loop, but the multi-select filedialog options don't seem to me to be the right source as these apply to existing files in a directory.

-Stewart
Jan 27 '10 #2
ADezii
8,834 Recognized Expert Expert
I too, like Stewart, am confused by your request. My interpretation is that you wish to simply create a Blank Excel Spreadsheet from a predetermined Path. If this is True, I'll post a general template that you can use, if not then you must provide additional, more specific, information.
Expand|Select|Wrap|Line Numbers
  1. 'Must Set a Reference to the Microsoft Excel XX.X Object Library
  2. Dim appExcel As Excel.Application
  3. Dim wBook As Workbook
  4.  
  5. If IsNull(Me![txtFilePath]) Then Exit Sub
  6.  
  7. Set appExcel = New Excel.Application
  8. Set wBook = appExcel.Workbooks.Add
  9.  
  10. wBook.SaveAs Me![txtFilePath]
  11.  
  12. appExcel.Quit
  13. Set appExcel = Nothing
Jan 27 '10 #3
Busbait
18 New Member
ADezii

“Create a Blank Excel Spreadsheet from a predetermined Path” ………. This is exactly what I was looking for

Thanks ADezii and Stewart
Jan 27 '10 #4
ADezii
8,834 Recognized Expert Expert
Just out of curiosity, Busbait, what exactly are you trying to accomplish?
Jan 27 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
2602
by: W.Guerlich | last post by:
I've got a Java servlet that delivers large database resultsets transformed to Excel with the HSSF library. In some cases it takes more than 15 minutes before transformation is done and content can be delivered to the browser. I want to show the "Save As" dialog as early as possible so the user knows he's not lost and forgotten. I already tried to send the response headers immediately after receiving the request including content...
3
11263
by: Maya | last post by:
Hey, there! I'm new to vb.net and it seems I wouldn't be able to solve this without help. I have a pipe delimited file that has to be saved in txt format so it could be accepted by my DTS package. If I open and save the file manualy in Wordpad - it works. (not in Notepad otherwise formatting is changed and DTS package won't accept it.)
4
3475
by: Aliza Klein | last post by:
I am new to ASP so please pardon me if this is crazy. I have data that I want to allow the user to be able to save in a format that will then enable the user to open the data in Excel. (I have already read the previous CSV posts and still have a question.) I have an ASP page that takes some data from a previous page,adds some column headings and displays it all in apparent CSV format. All I am trying to do is allow the users to do a...
4
4531
by: Jae | last post by:
I'm writing a web application that exports and imports excel files. The application gets a list of users and their info and displays it in a datagrid .The user then selects to save the file as a tab delimited file or an excel file. The application then saves the file in the correct format. The flip side is for the user to import/upload the file to the server The application must be able to import the excel file and read the contents. I...
2
2187
by: PB | last post by:
I need to enable users to download data in either an Excel file or an Access database (MDB file). The data they need exists in a SQL Server database: the XLS or MDB file does not actually exist at the time the users request it. My initial plan is that when users request their data, they will click a button or link indicating that they want their data in the respective file format. Then, on the server I want to execute a stored...
2
2491
by: monsieur.marco | last post by:
Hi all, Does anybody know how to save localization in an excel workbook (C# 1.1)? I'm not sure this is possible, but I'm trying to do this so that numberColumns keep their format no matter what local is set in the computer where the file is opened. Thanks in advance, Swayze
1
1830
by: anjupt | last post by:
Hi, I can export a datagrid into excel format by following code on button click "Response.ContentType = "application/vnd.ms-excel" clicking on the button open a dialog box asking whether to open the file or save the file from which we choose open and the datagrid opens in excel format. What i want is on button click i want the datagrid to be saved into a specific folder in excel format without any dialog box poping up
0
5736
Boxcar74
by: Boxcar74 | last post by:
Hi Everybody!!! I have an Issue. I have an Excel file that queries an Access db. I’m trying to have it so I don’t have to keep updating it manually everyday and save it to a network drive with the file name coming from a cell reference and the current date. What I’ve done have the Excel file open via a Batch file and on “Workbook_Open” I run a few macro to refresh the data then remake and save it to the network drive. My...
2
3030
by: chike_oji | last post by:
Please can someone help me. I am writing a web application, that allows for the upload of an excel sheet into the database. I have an upload button and a save button. The upload button allows for the retrieval of the excel data into a DataTable, which is bound to a GridView for previewing before saving to the Database. But, whenever I click on the save button, I lose the DataTable's data, so I lose the data I want to save to the...
3
7161
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I have a question for you. I have a .csv file which has many lines of data. Each line has many data fields which are delimited by ",". Now I need to extract part of data from this file but save it as an excel file. The data in this excel file will be imported into an Access database. The
0
9706
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9503
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9474
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9377
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8372
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6921
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6191
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4983
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2924
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.