Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
BH BH is offline
external usenet poster
 
Posts: 14
Default create a macro to automaticaly name a file.

I need to have control over file naming in a worksheet would like to be able
to do this by assiging a macro to a button.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 292
Default create a macro to automaticaly name a file.

Write a macro containing something like
ActiveWorkbook.SaveAs "C:\Temp\MyFile.xls"
and assign it to your button.

HTH. Best wishes Harald


"bh" skrev i melding
...
I need to have control over file naming in a worksheet would like to be

able
to do this by assiging a macro to a button.



  #3   Report Post  
Posted to microsoft.public.excel.programming
BH BH is offline
external usenet poster
 
Posts: 14
Default create a macro to automaticaly name a file.

Harald: Is it possible to pull the information out of a cell entered in the
worksheet?
Thanks
BH

"Harald Staff" wrote:

Write a macro containing something like
ActiveWorkbook.SaveAs "C:\Temp\MyFile.xls"
and assign it to your button.

HTH. Best wishes Harald


"bh" skrev i melding
...
I need to have control over file naming in a worksheet would like to be

able
to do this by assiging a macro to a button.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default create a macro to automaticaly name a file.

Write a macro containing something like
ActiveWorkbook.SaveAs Activesheet.Range("B9").Value


where cell B9 contains the string

C:\Temp\MyFile.xls

--
Regards,
Tom Ogilvy

"BH" wrote in message
...
Harald: Is it possible to pull the information out of a cell entered in

the
worksheet?
Thanks
BH

"Harald Staff" wrote:

Write a macro containing something like
ActiveWorkbook.SaveAs "C:\Temp\MyFile.xls"
and assign it to your button.

HTH. Best wishes Harald


"bh" skrev i melding
...
I need to have control over file naming in a worksheet would like to

be
able
to do this by assiging a macro to a button.






  #5   Report Post  
Posted to microsoft.public.excel.programming
BH BH is offline
external usenet poster
 
Posts: 14
Default create a macro to automaticaly name a file.

Tom:
Were do I inserte the file path.

"Tom Ogilvy" wrote:

Write a macro containing something like
ActiveWorkbook.SaveAs Activesheet.Range("B9").Value


where cell B9 contains the string

C:\Temp\MyFile.xls

--
Regards,
Tom Ogilvy

"BH" wrote in message
...
Harald: Is it possible to pull the information out of a cell entered in

the
worksheet?
Thanks
BH

"Harald Staff" wrote:

Write a macro containing something like
ActiveWorkbook.SaveAs "C:\Temp\MyFile.xls"
and assign it to your button.

HTH. Best wishes Harald


"bh" skrev i melding
...
I need to have control over file naming in a worksheet would like to

be
able
to do this by assiging a macro to a button.








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default create a macro to automaticaly name a file.

if B9 contains the string C:\Temp\MyFile.xls

then C:\Temp\ is the file path.

The activeworkbook is saved to the C:\Temp directory with a filename of
MyFile.xls
--
Regards,
Tom Ogilvy


"BH" wrote in message
...
Tom:
Were do I inserte the file path.

"Tom Ogilvy" wrote:

Write a macro containing something like
ActiveWorkbook.SaveAs Activesheet.Range("B9").Value


where cell B9 contains the string

C:\Temp\MyFile.xls

--
Regards,
Tom Ogilvy

"BH" wrote in message
...
Harald: Is it possible to pull the information out of a cell entered

in
the
worksheet?
Thanks
BH

"Harald Staff" wrote:

Write a macro containing something like
ActiveWorkbook.SaveAs "C:\Temp\MyFile.xls"
and assign it to your button.

HTH. Best wishes Harald


"bh" skrev i melding
...
I need to have control over file naming in a worksheet would like

to
be
able
to do this by assiging a macro to a button.








  #7   Report Post  
Posted to microsoft.public.excel.programming
BH BH is offline
external usenet poster
 
Posts: 14
Default create a macro to automaticaly name a file.

Tom;
I am looking to have the file name be what ever I enter into cell B9.
Thanks

"Tom Ogilvy" wrote:

if B9 contains the string C:\Temp\MyFile.xls

then C:\Temp\ is the file path.

The activeworkbook is saved to the C:\Temp directory with a filename of
MyFile.xls
--
Regards,
Tom Ogilvy


"BH" wrote in message
...
Tom:
Were do I inserte the file path.

"Tom Ogilvy" wrote:

Write a macro containing something like
ActiveWorkbook.SaveAs Activesheet.Range("B9").Value

where cell B9 contains the string

C:\Temp\MyFile.xls

--
Regards,
Tom Ogilvy

"BH" wrote in message
...
Harald: Is it possible to pull the information out of a cell entered

in
the
worksheet?
Thanks
BH

"Harald Staff" wrote:

Write a macro containing something like
ActiveWorkbook.SaveAs "C:\Temp\MyFile.xls"
and assign it to your button.

HTH. Best wishes Harald


"bh" skrev i melding
...
I need to have control over file naming in a worksheet would like

to
be
able
to do this by assiging a macro to a button.









  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default create a macro to automaticaly name a file.

sPath = "C:\Temp\"
ActiveWorkbook.SaveAs sPath & Activesheet.Range("B9").Value

where cell B9 contains the name you want.

------------------

if you want the path in B8 and the name in B9

sPath = Range("B8").Value
if Right(spath,1) < "\" then sPath = sPath & "\"
ActiveWorkbook.SaveAs sPath & Activesheet.Range("B9").Value

------------------


If you want to save in the same location as the activeworkbook currently is
located

sPath = ActiveWorkbook.Path
if Right(spath,1) < "\" then sPath = sPath & "\"
ActiveWorkbook.SaveAs sPath & Activesheet.Range("B9").Value

--
Regards,
Tom Ogilvy


"BH" wrote in message
...
Tom;
I am looking to have the file name be what ever I enter into cell B9.
Thanks

"Tom Ogilvy" wrote:

if B9 contains the string C:\Temp\MyFile.xls

then C:\Temp\ is the file path.

The activeworkbook is saved to the C:\Temp directory with a filename of
MyFile.xls
--
Regards,
Tom Ogilvy


"BH" wrote in message
...
Tom:
Were do I inserte the file path.

"Tom Ogilvy" wrote:

Write a macro containing something like
ActiveWorkbook.SaveAs Activesheet.Range("B9").Value

where cell B9 contains the string

C:\Temp\MyFile.xls

--
Regards,
Tom Ogilvy

"BH" wrote in message
...
Harald: Is it possible to pull the information out of a cell

entered
in
the
worksheet?
Thanks
BH

"Harald Staff" wrote:

Write a macro containing something like
ActiveWorkbook.SaveAs "C:\Temp\MyFile.xls"
and assign it to your button.

HTH. Best wishes Harald


"bh" skrev i melding
...
I need to have control over file naming in a worksheet would

like
to
be
able
to do this by assiging a macro to a button.











  #9   Report Post  
Posted to microsoft.public.excel.programming
BH BH is offline
external usenet poster
 
Posts: 14
Default create a macro to automaticaly name a file.

Tom:

"Tom Ogilvy" wrote:

sPath = "C:\Temp\"
ActiveWorkbook.SaveAs sPath & Activesheet.Range("B9").Value

where cell B9 contains the name you want.

------------------

if you want the path in B8 and the name in B9

sPath = Range("B8").Value
if Right(spath,1) < "\" then sPath = sPath & "\"
ActiveWorkbook.SaveAs sPath & Activesheet.Range("B9").Value

------------------


If you want to save in the same location as the activeworkbook currently is
located

sPath = ActiveWorkbook.Path
if Right(spath,1) < "\" then sPath = sPath & "\"
ActiveWorkbook.SaveAs sPath & Activesheet.Range("B9").Value

--
Regards,
Tom Ogilvy


"BH" wrote in message
...
Tom;
I am looking to have the file name be what ever I enter into cell B9.
Thanks

"Tom Ogilvy" wrote:

if B9 contains the string C:\Temp\MyFile.xls

then C:\Temp\ is the file path.

The activeworkbook is saved to the C:\Temp directory with a filename of
MyFile.xls
--
Regards,
Tom Ogilvy


"BH" wrote in message
...
Tom:
Were do I inserte the file path.

"Tom Ogilvy" wrote:

Write a macro containing something like
ActiveWorkbook.SaveAs Activesheet.Range("B9").Value

where cell B9 contains the string

C:\Temp\MyFile.xls

--
Regards,
Tom Ogilvy

"BH" wrote in message
...
Harald: Is it possible to pull the information out of a cell

entered
in
the
worksheet?
Thanks
BH

"Harald Staff" wrote:

Write a macro containing something like
ActiveWorkbook.SaveAs "C:\Temp\MyFile.xls"
and assign it to your button.

HTH. Best wishes Harald


"bh" skrev i melding
...
I need to have control over file naming in a worksheet would

like
to
be
able
to do this by assiging a macro to a button.












  #10   Report Post  
Posted to microsoft.public.excel.programming
BH BH is offline
external usenet poster
 
Posts: 14
Default create a macro to automaticaly name a file.

All I am trying to do is place a command button on a form that will name the
file from a cell and save the file under that name , I have not had any luck
so far. I may not be seeting up the macro the right way.

"Tom Ogilvy" wrote:

sPath = "C:\Temp\"
ActiveWorkbook.SaveAs sPath & Activesheet.Range("B9").Value

where cell B9 contains the name you want.

------------------

if you want the path in B8 and the name in B9

sPath = Range("B8").Value
if Right(spath,1) < "\" then sPath = sPath & "\"
ActiveWorkbook.SaveAs sPath & Activesheet.Range("B9").Value

------------------


If you want to save in the same location as the activeworkbook currently is
located

sPath = ActiveWorkbook.Path
if Right(spath,1) < "\" then sPath = sPath & "\"
ActiveWorkbook.SaveAs sPath & Activesheet.Range("B9").Value

--
Regards,
Tom Ogilvy


"BH" wrote in message
...
Tom;
I am looking to have the file name be what ever I enter into cell B9.
Thanks

"Tom Ogilvy" wrote:

if B9 contains the string C:\Temp\MyFile.xls

then C:\Temp\ is the file path.

The activeworkbook is saved to the C:\Temp directory with a filename of
MyFile.xls
--
Regards,
Tom Ogilvy


"BH" wrote in message
...
Tom:
Were do I inserte the file path.

"Tom Ogilvy" wrote:

Write a macro containing something like
ActiveWorkbook.SaveAs Activesheet.Range("B9").Value

where cell B9 contains the string

C:\Temp\MyFile.xls

--
Regards,
Tom Ogilvy

"BH" wrote in message
...
Harald: Is it possible to pull the information out of a cell

entered
in
the
worksheet?
Thanks
BH

"Harald Staff" wrote:

Write a macro containing something like
ActiveWorkbook.SaveAs "C:\Temp\MyFile.xls"
and assign it to your button.

HTH. Best wishes Harald


"bh" skrev i melding
...
I need to have control over file naming in a worksheet would

like
to
be
able
to do this by assiging a macro to a button.














  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default create a macro to automaticaly name a file.

You may want to post the code that's failing (don't attach the workbook).

BH wrote:

All I am trying to do is place a command button on a form that will name the
file from a cell and save the file under that name , I have not had any luck
so far. I may not be seeting up the macro the right way.

  #12   Report Post  
Posted to microsoft.public.excel.programming
BH BH is offline
external usenet poster
 
Posts: 14
Default create a macro to automaticaly name a file.

ActiveWorkbook.SaveAs sPath & Activesheet.Range("B9").Value

"Dave Peterson" wrote:

You may want to post the code that's failing (don't attach the workbook).

BH wrote:

All I am trying to do is place a command button on a form that will name the
file from a cell and save the file under that name , I have not had any luck
so far. I may not be seeting up the macro the right way.


  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default create a macro to automaticaly name a file.

What's in B9?

There are some characters that can't be used in file names (like *, /, \).

(Make sure you're looking at the correct sheet, too. Maybe the wrong sheet is
active.)

BH wrote:

ActiveWorkbook.SaveAs sPath & Activesheet.Range("B9").Value

"Dave Peterson" wrote:

You may want to post the code that's failing (don't attach the workbook).

BH wrote:

All I am trying to do is place a command button on a form that will name the
file from a cell and save the file under that name , I have not had any luck
so far. I may not be seeting up the macro the right way.



--

Dave Peterson
  #14   Report Post  
Posted to microsoft.public.excel.programming
BH BH is offline
external usenet poster
 
Posts: 14
Default create a macro to automaticaly name a file.

B9 will be a field that is entered by the user it will contain text,or
numerical values.

"Dave Peterson" wrote:

What's in B9?

There are some characters that can't be used in file names (like *, /, \).

(Make sure you're looking at the correct sheet, too. Maybe the wrong sheet is
active.)

BH wrote:

ActiveWorkbook.SaveAs sPath & Activesheet.Range("B9").Value

"Dave Peterson" wrote:

You may want to post the code that's failing (don't attach the workbook).

BH wrote:

All I am trying to do is place a command button on a form that will name the
file from a cell and save the file under that name , I have not had any luck
so far. I may not be seeting up the macro the right way.



--

Dave Peterson

  #15   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default create a macro to automaticaly name a file.

I meant what was in B9 when the code failed?

msgbox "***" & activesheet.range("b9").value & "***"

would show you the value surrounded by asterisks.

BH wrote:

B9 will be a field that is entered by the user it will contain text,or
numerical values.

"Dave Peterson" wrote:

What's in B9?

There are some characters that can't be used in file names (like *, /, \).

(Make sure you're looking at the correct sheet, too. Maybe the wrong sheet is
active.)

BH wrote:

ActiveWorkbook.SaveAs sPath & Activesheet.Range("B9").Value

"Dave Peterson" wrote:

You may want to post the code that's failing (don't attach the workbook).

BH wrote:

All I am trying to do is place a command button on a form that will name the
file from a cell and save the file under that name , I have not had any luck
so far. I may not be seeting up the macro the right way.



--

Dave Peterson


--

Dave Peterson


  #16   Report Post  
Posted to microsoft.public.excel.programming
BH BH is offline
external usenet poster
 
Posts: 14
Default create a macro to automaticaly name a file.

There was not anything in the b9 cell. I am new to the use of macros and need
a step by setp layout of what I need to do. I am tring to set up a templet
that I will have control over the file name by entering data into a cell. So
if I ener a name in cell b9 I when I click my command button I would like to
have the file saved as the name in cell b9.

"Dave Peterson" wrote:

I meant what was in B9 when the code failed?

msgbox "***" & activesheet.range("b9").value & "***"

would show you the value surrounded by asterisks.

BH wrote:

B9 will be a field that is entered by the user it will contain text,or
numerical values.

"Dave Peterson" wrote:

What's in B9?

There are some characters that can't be used in file names (like *, /, \).

(Make sure you're looking at the correct sheet, too. Maybe the wrong sheet is
active.)

BH wrote:

ActiveWorkbook.SaveAs sPath & Activesheet.Range("B9").Value

"Dave Peterson" wrote:

You may want to post the code that's failing (don't attach the workbook).

BH wrote:

All I am trying to do is place a command button on a form that will name the
file from a cell and save the file under that name , I have not had any luck
so far. I may not be seeting up the macro the right way.



--

Dave Peterson


--

Dave Peterson

  #17   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default create a macro to automaticaly name a file.

You could check to see if there is anything in that cell before you try to save
the workbook:

if isempty(activesheet.range("b9")) then
msgbox "Please put something in B9!"
exit sub
end if

'rest of code here.

=====
but there's lots of things that you could put in B9 that would make the save
fail. Sometimes it's just better to try it and then check to see if it was
successful:

Option Explicit
Sub testme()
Dim sPath As String
sPath = "c:\my documents\excel\"

On Error Resume Next
ActiveWorkbook.SaveAs sPath & ActiveSheet.Range("B9").Value
If Err.Number < 0 Then
MsgBox "File not saved!" & vbLf & "Please check B9"
Err.Clear
End If

End Sub



BH wrote:

There was not anything in the b9 cell. I am new to the use of macros and need
a step by setp layout of what I need to do. I am tring to set up a templet
that I will have control over the file name by entering data into a cell. So
if I ener a name in cell b9 I when I click my command button I would like to
have the file saved as the name in cell b9.

"Dave Peterson" wrote:

I meant what was in B9 when the code failed?

msgbox "***" & activesheet.range("b9").value & "***"

would show you the value surrounded by asterisks.

BH wrote:

B9 will be a field that is entered by the user it will contain text,or
numerical values.

"Dave Peterson" wrote:

What's in B9?

There are some characters that can't be used in file names (like *, /, \).

(Make sure you're looking at the correct sheet, too. Maybe the wrong sheet is
active.)

BH wrote:

ActiveWorkbook.SaveAs sPath & Activesheet.Range("B9").Value

"Dave Peterson" wrote:

You may want to post the code that's failing (don't attach the workbook).

BH wrote:

All I am trying to do is place a command button on a form that will name the
file from a cell and save the file under that name , I have not had any luck
so far. I may not be seeting up the macro the right way.



--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
  #18   Report Post  
Posted to microsoft.public.excel.programming
BH BH is offline
external usenet poster
 
Posts: 14
Default create a macro to automaticaly name a file.

Thanks a million.

"Dave Peterson" wrote:

I meant what was in B9 when the code failed?

msgbox "***" & activesheet.range("b9").value & "***"

would show you the value surrounded by asterisks.

BH wrote:

B9 will be a field that is entered by the user it will contain text,or
numerical values.

"Dave Peterson" wrote:

What's in B9?

There are some characters that can't be used in file names (like *, /, \).

(Make sure you're looking at the correct sheet, too. Maybe the wrong sheet is
active.)

BH wrote:

ActiveWorkbook.SaveAs sPath & Activesheet.Range("B9").Value

"Dave Peterson" wrote:

You may want to post the code that's failing (don't attach the workbook).

BH wrote:

All I am trying to do is place a command button on a form that will name the
file from a cell and save the file under that name , I have not had any luck
so far. I may not be seeting up the macro the right way.



--

Dave Peterson


--

Dave Peterson

  #19   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default create a macro to automaticaly name a file.

I do not have a lot of experience attaching documents. I am applying for a
job and I have to attach all my documents and it keeps coming back as an error

"bh" wrote:

I need to have control over file naming in a worksheet would like to be able
to do this by assiging a macro to a button.

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
excel file opened automaticaly at specified time & date aligaz Excel Discussion (Misc queries) 2 December 17th 07 04:45 PM
Can you automaticaly save a shared file every few mintues? Ben Excel Discussion (Misc queries) 0 February 7th 07 03:23 PM
Automaticaly create montly calendars for 30 employees YanYan Excel Discussion (Misc queries) 1 November 15th 05 01:01 AM
macro to save file automaticaly? david Excel Discussion (Misc queries) 1 May 6th 05 05:21 PM
Excel File To update Automaticaly Tom Ogilvy Excel Programming 0 September 3rd 03 12:21 PM


All times are GMT +1. The time now is 10:32 AM.

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

About Us

"It's about Microsoft Excel"