PC Review


Reply
Thread Tools Rate Thread

auto save when form is closed

 
 
tpeter
Guest
Posts: n/a
 
      8th Apr 2009
I have a userform that pops up when a file is open to make sure all of the
data goes into the correct place. I would like to add 1 more textbox that
would give the used the ability to type in the file name, an example would be
4-4-08 Run 1. When the form is closed I would like to have the file
automatically saved to a certian location with the file name added. An
example would be I/work/engineeringdata/productdata/meters/turbine/(file name
entered by user).xls. I could make a macro to run on the forms close to save
the file name but am unsure how to attache the userinfo to the path and name.
Thank you for your help.

Tim Peter
 
Reply With Quote
 
 
 
 
Jeff
Guest
Posts: n/a
 
      8th Apr 2009
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
ThisWorkbook.Save
End Sub


"tpeter" wrote:

> I have a userform that pops up when a file is open to make sure all of the
> data goes into the correct place. I would like to add 1 more textbox that
> would give the used the ability to type in the file name, an example would be
> 4-4-08 Run 1. When the form is closed I would like to have the file
> automatically saved to a certian location with the file name added. An
> example would be I/work/engineeringdata/productdata/meters/turbine/(file name
> entered by user).xls. I could make a macro to run on the forms close to save
> the file name but am unsure how to attache the userinfo to the path and name.
> Thank you for your help.
>
> Tim Peter

 
Reply With Quote
 
Jeff
Guest
Posts: n/a
 
      8th Apr 2009
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Application.Dialogs(xlDialogSaveAs).Show ("4-4-08 Run 1")
End Sub


"tpeter" wrote:

> I have a userform that pops up when a file is open to make sure all of the
> data goes into the correct place. I would like to add 1 more textbox that
> would give the used the ability to type in the file name, an example would be
> 4-4-08 Run 1. When the form is closed I would like to have the file
> automatically saved to a certian location with the file name added. An
> example would be I/work/engineeringdata/productdata/meters/turbine/(file name
> entered by user).xls. I could make a macro to run on the forms close to save
> the file name but am unsure how to attache the userinfo to the path and name.
> Thank you for your help.
>
> Tim Peter

 
Reply With Quote
 
tpeter
Guest
Posts: n/a
 
      8th Apr 2009
Jeff,

That worked great thank you. I subsituted ("4-4-08 Run 1") for ("textbox26")
and it did exaclty what I wanted. I still need to be able to put the path
into this location.I:\work\Engineering Data\Product Data\Meters\Turbine
Meters, I have tried putting it into the () and outside and I get an error.
Any idea's? Thank you again for your help.

"Jeff" wrote:

> Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
> Application.Dialogs(xlDialogSaveAs).Show ("4-4-08 Run 1")
> End Sub
>
>
> "tpeter" wrote:
>
> > I have a userform that pops up when a file is open to make sure all of the
> > data goes into the correct place. I would like to add 1 more textbox that
> > would give the used the ability to type in the file name, an example would be
> > 4-4-08 Run 1. When the form is closed I would like to have the file
> > automatically saved to a certian location with the file name added. An
> > example would be I/work/engineeringdata/productdata/meters/turbine/(file name
> > entered by user).xls. I could make a macro to run on the forms close to save
> > the file name but am unsure how to attache the userinfo to the path and name.
> > Thank you for your help.
> >
> > Tim Peter

 
Reply With Quote
 
Jeff
Guest
Posts: n/a
 
      8th Apr 2009
Try this

Option Explicit
Private Const fPath As String = "I:\work\Engineering Data\Product
Data\Meters\Turbine Meters\"
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
ThisWorkbook.SaveCopyAs (fPath & Chr(32) & TextBox26)
End Sub


"tpeter" wrote:

> Jeff,
>
> That worked great thank you. I subsituted ("4-4-08 Run 1") for ("textbox26")
> and it did exaclty what I wanted. I still need to be able to put the path
> into this location.I:\work\Engineering Data\Product Data\Meters\Turbine
> Meters, I have tried putting it into the () and outside and I get an error.
> Any idea's? Thank you again for your help.
>
> "Jeff" wrote:
>
> > Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
> > Application.Dialogs(xlDialogSaveAs).Show ("4-4-08 Run 1")
> > End Sub
> >
> >
> > "tpeter" wrote:
> >
> > > I have a userform that pops up when a file is open to make sure all of the
> > > data goes into the correct place. I would like to add 1 more textbox that
> > > would give the used the ability to type in the file name, an example would be
> > > 4-4-08 Run 1. When the form is closed I would like to have the file
> > > automatically saved to a certian location with the file name added. An
> > > example would be I/work/engineeringdata/productdata/meters/turbine/(file name
> > > entered by user).xls. I could make a macro to run on the forms close to save
> > > the file name but am unsure how to attache the userinfo to the path and name.
> > > Thank you for your help.
> > >
> > > Tim Peter

 
Reply With Quote
 
tpeter
Guest
Posts: n/a
 
      8th Apr 2009
Jeff,

I tried this and can't tell if it is working or not. fPath is breaking the
code. I have made sure the path is correct for my network and gotten rid of
the : between I and Work but it still breaks. Any Idea's? Thanks again for
your assistance.

"Jeff" wrote:

> Try this
>
> Option Explicit
> Private Const fPath As String = "I:\work\Engineering Data\Product
> Data\Meters\Turbine Meters\"
> Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
> ThisWorkbook.SaveCopyAs (fPath & Chr(32) & TextBox26)
> End Sub
>
>
> "tpeter" wrote:
>
> > Jeff,
> >
> > That worked great thank you. I subsituted ("4-4-08 Run 1") for ("textbox26")
> > and it did exaclty what I wanted. I still need to be able to put the path
> > into this location.I:\work\Engineering Data\Product Data\Meters\Turbine
> > Meters, I have tried putting it into the () and outside and I get an error.
> > Any idea's? Thank you again for your help.
> >
> > "Jeff" wrote:
> >
> > > Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
> > > Application.Dialogs(xlDialogSaveAs).Show ("4-4-08 Run 1")
> > > End Sub
> > >
> > >
> > > "tpeter" wrote:
> > >
> > > > I have a userform that pops up when a file is open to make sure all of the
> > > > data goes into the correct place. I would like to add 1 more textbox that
> > > > would give the used the ability to type in the file name, an example would be
> > > > 4-4-08 Run 1. When the form is closed I would like to have the file
> > > > automatically saved to a certian location with the file name added. An
> > > > example would be I/work/engineeringdata/productdata/meters/turbine/(file name
> > > > entered by user).xls. I could make a macro to run on the forms close to save
> > > > the file name but am unsure how to attache the userinfo to the path and name.
> > > > Thank you for your help.
> > > >
> > > > Tim Peter

 
Reply With Quote
 
Jeff
Guest
Posts: n/a
 
      8th Apr 2009
this should do it....


Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Dim fPath As String ' Variable to hold filepath
Dim fExtention As String 'Variable to hold File Extention
Dim txtBoxValue As String 'Variable to hold TextBox Value
Dim SavePath As String 'Variable to define final file path

'in your case this should be _
I:\work\Engineering Data\Product Data\Meters\Turbine Meters\
fPath = "C:\Documents and Settings\User\Desktop\"

' I am assuming you want to save this as an ".xls"
'but it can be whatever you need.
fExtention = ".xls"

'This Just stores the TextBox26 value
txtBoxValue = UserForm1.TextBox26.Value

'Packages it all up to a nice neat variable.
SavePath = fPath & txtBoxValue & fExtention

'Saves a copy of the active workbook to the
'specified location.
ThisWorkbook.SaveCopyAs (SavePath)
End Sub




"tpeter" wrote:

> Jeff,
>
> I tried this and can't tell if it is working or not. fPath is breaking the
> code. I have made sure the path is correct for my network and gotten rid of
> the : between I and Work but it still breaks. Any Idea's? Thanks again for
> your assistance.
>
> "Jeff" wrote:
>
> > Try this
> >
> > Option Explicit
> > Private Const fPath As String = "I:\work\Engineering Data\Product
> > Data\Meters\Turbine Meters\"
> > Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
> > ThisWorkbook.SaveCopyAs (fPath & Chr(32) & TextBox26)
> > End Sub
> >
> >
> > "tpeter" wrote:
> >
> > > Jeff,
> > >
> > > That worked great thank you. I subsituted ("4-4-08 Run 1") for ("textbox26")
> > > and it did exaclty what I wanted. I still need to be able to put the path
> > > into this location.I:\work\Engineering Data\Product Data\Meters\Turbine
> > > Meters, I have tried putting it into the () and outside and I get an error.
> > > Any idea's? Thank you again for your help.
> > >
> > > "Jeff" wrote:
> > >
> > > > Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
> > > > Application.Dialogs(xlDialogSaveAs).Show ("4-4-08 Run 1")
> > > > End Sub
> > > >
> > > >
> > > > "tpeter" wrote:
> > > >
> > > > > I have a userform that pops up when a file is open to make sure all of the
> > > > > data goes into the correct place. I would like to add 1 more textbox that
> > > > > would give the used the ability to type in the file name, an example would be
> > > > > 4-4-08 Run 1. When the form is closed I would like to have the file
> > > > > automatically saved to a certian location with the file name added. An
> > > > > example would be I/work/engineeringdata/productdata/meters/turbine/(file name
> > > > > entered by user).xls. I could make a macro to run on the forms close to save
> > > > > the file name but am unsure how to attache the userinfo to the path and name.
> > > > > Thank you for your help.
> > > > >
> > > > > Tim Peter

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Save form, auto open anther form and populate field =?Utf-8?B?bWFseWNvbQ==?= Microsoft Access 1 19th Apr 2007 02:26 PM
HOW TO MAKE THE FORM NOT AUTO SAVE EMILYTAN via AccessMonster.com Microsoft Access Form Coding 1 13th Apr 2007 11:04 AM
Stop form being closed before save button is clicked =?Utf-8?B?RGVicmE=?= Microsoft Access Forms 1 9th Oct 2006 01:04 PM
Disabling auto save for a form =?Utf-8?B?Sm9obiBIIFc=?= Microsoft Access Form Coding 0 23rd Jun 2005 05:43 PM
HOW: Skipping 'Do you want to save changes' when form is closed =?Utf-8?B?Qkc=?= Microsoft Outlook VBA Programming 3 14th Jan 2004 02:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:17 PM.