Creating a new workbook...

09-01-2004, 08:15 AM
Hi there. I got a userform and a textbox1 for input of a name. When user enters a user name and presses the commandbutton, the vba code will duplicate another excel file (*.xls) with the file name = the inputted user name and all the features from the source file (i.e. the current processing file). How can I do that in VBA code? And, can I update the cell values of the file B using VBA code in file A?


09-01-2004, 09:07 AM
Is the duplicated workbook the same every time?And, can I update the cell values of the file B using VBA code in file A?Yes you can. You will have to make reference to this new workbook like
With Workbooks("My New One")
With Worksheets("This one too")
.Range("A1").value = "yabadabadoo!!"
End With
End With

09-01-2004, 09:22 AM
Hi there. Yes, indeed. It's like a model workbook...with only different filename.


09-01-2004, 09:28 AM
then look in the help files for the SaveAs Method... and of course once you get the name of the new file, you only need to concatenate it to make a valid name :)

Mike Rosenblum
09-01-2004, 08:04 PM
I'm not quite sure that I follow what you mean here. But would 'Workbook.SaveCopyAs()' be of use to you? I think this is what you are essentially destribing, I think...

09-01-2004, 08:47 PM
maybe you can try this, i works for me if i need to do auto backup for my excel files. Remeber to include the excel reference.

Dim wb As Excel.Workbook
Set wb = Workbooks.Open("oldFileName.xls")

09-02-2004, 03:56 AM

Could this be what you are looking for?


09-02-2004, 08:49 AM
Hi there. Thanks guys. Your advice helps me a lot.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum