Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default Export user inputs to a template and save it as a different file

Hi All,

I have a userfrom designed in workbook1 which accepts user inptus and has a
"submit" button, On clicking submit button I want to export the user inputs
to a seperate workbook lets say workbook2 (which will act as a template). Now
I dont want this workbook to save, But save it as workbook3. so basically
workbook3 is the exact same copy of workbook 2 but with user inputs, and
workbook2 will always remain empty and act as a template.
SO everytime a user inputs and clicks "submit" I want the inputs to be
exported to workbook2 which will then be saved as workbook3..

Hope I am clear.

Thanks in advance
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Export user inputs to a template and save it as a different file

Hi Sam,
Not fully sure really understand your workflow but as a suggestion:

1 - keep the template in workbook 1
2 - populate with data from your form
3 - copy template to new workbook
4 - save new workbook (your workbook 3)
5 €“ close (if required)

following code is not a solution more an idea. It captures textbox values in
to an array which you would then assign to the required ranges in your
template.

When done, template is copied and saved as new workbook. You can add code to
delete values from template afterwards if needed.

code goes behind your form €“ as said, not a solution but may give you some
ideas.

note: I use 2003 and SaveAs portion of code may need updating if you use 2007.

Hope helpful


Private Sub CommandButton1_Click()

Dim ctl As Control
Dim myarray() As String
Dim NewWB As Workbook
Dim ws As Worksheet


i = 0
For Each ctl In Me.Controls

If TypeName(ctl) = "TextBox" Then

ReDim Preserve myarray(i)

myarray(i) = ctl.Value

i = i + 1

End If

Next

Set ws = Worksheets("Template")


For i = LBound(myarray) To UBound(myarray)

With ws

'add my array values
'to required template sheet ranges

End With

MsgBox myarray(i)

Next

'copy template
ws.Copy

Set NewWB = ActiveWorkbook

'save & close
With NewWB

.SaveAs "C:\template.xls"

.Close False

End With

End Sub

--
jb


"sam" wrote:

Hi All,

I have a userfrom designed in workbook1 which accepts user inptus and has a
"submit" button, On clicking submit button I want to export the user inputs
to a seperate workbook lets say workbook2 (which will act as a template). Now
I dont want this workbook to save, But save it as workbook3. so basically
workbook3 is the exact same copy of workbook 2 but with user inputs, and
workbook2 will always remain empty and act as a template.
SO everytime a user inputs and clicks "submit" I want the inputs to be
exported to workbook2 which will then be saved as workbook3..

Hope I am clear.

Thanks in advance

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
save user inputs from userform in a seperate workbook sam Excel Programming 6 July 16th 09 07:59 AM
Do not let user save template if it has been been modified Maddoktor Excel Programming 1 January 17th 07 11:49 PM
prompt user to save file as {desired_name} and save it to a variab GeneWan Excel Programming 1 January 5th 07 06:46 AM
Save user-defined chart types in a shared Excel template? graphicslady Charts and Charting in Excel 7 September 7th 06 02:07 PM
Macro to export a worksheet and save as new file Mike_M Excel Programming 2 May 25th 05 10:37 AM


All times are GMT +1. The time now is 05:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"