Export data to existing Excel file

N

nopcworries

I have created a macro that pulls out timephased data based on the user
entering start and end dates, and selecting an option button on a form. I'm
able to export it to Excel based on JackD's posts and referencing his
Website. But I would like to export data to an existing Excel workbook, not
create a new one. I'm not quite sure how to do that.

At first I would just hard code the path, but eventually I would want to
prompt the user to browse for an existing file.

I'm using Project 2002 Standard
I have Excel 2002

Thanks,
Eric
 
J

JackD

You can use the filedialog object from Office VBA.
I don't think it is present in Project, but if you create an instance of
excel you can access it there. There is help in the excel file for this.

Here is an example of how to use it in Access

Sub getFileNames()
Dim fDialog As FileDialog
Set fDialog = Application.FileDialog(msoFileDialogOpen)
Dim fName As Variant
With fDialog
.AllowMultiSelect = True
.Filters.Clear
..Filters.Add "Excel Files", "*.xls; *.XLS", 1
.Show
End With
For Each fName In fDialog.SelectedItems
MsgBox fName
Next fName
Set fDialog = Nothing
End Sub

The next steps for you are to modify it so multiselect is false and then use
fName as the argument to open the excel file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top