Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Saving a workbook

I am using Excel 2003. I have a workbook named Main.xls I have a
worksheet in Main.xls named Ticket Cell j8 of Ticket contains a
ticket number such as NT0104, Cell b8 in ticket contains a co. name such
as Exxon, and cell b200 in ticket contains a dir path such as
c:\2009\Feb\ . I want to save the workbook main.xls to the new name
(in this case NT0104Exxon.xls) to the specified dir path (in this case
c:\2009\Feb) and then I want to keep the original workbook, Main.xls open.
When I run the following code, it saves NT0104Exxon.xls to My documents
instead of to c:\2009\Feb and then it closes the workbook. I would
appreciate any help on what I am doing wrong.
Here's the code:

rem sitting up variable that will determine where the files will be saved.

Dim strappend As String
Dim strpath As String
Dim str3 As String




Sheets("ticket").Select

strappend = ActiveSheet.Range("j8").Value
strpath = ActiveSheet.Range("b200").Value
str3 = ActiveSheet.Range("c8").Value

Rem Setting fsavename to directory and file
fsavename = strpth & strappend & str3 & ".xls"

Rem Saving the file fsavename to the designated directory

ThisWorkbook.SaveAs Filename:=fsavename

Rem this keeps the main workbook open
ActiveWorkbook.Close False
end sub

Thanks in advance for the help

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Saving a workbook

try this code


oldname = ThisWorkbook.FullName

Dim strappend As String
Dim strpath As String
Dim str3 As String

With ThisWorkbook.Sheets("ticket")
oldname = ThisWorkbook.FullName

strappend = .Range("j8").Value
strpath = .Range("b200").Value
str3 = .Range("c8").Value

Rem Setting fsavename to directory and file
fsavename = strpth & strappend & str3 & ".xls"

Rem Saving the file fsavename to the designated directory

ThisWorkbook.SaveAs Filename:=fsavename

Rem this keeps the main workbook open
Set Newbk = ActiveWorkbook

Set Oldbk = Workbooks.Open(Filename:=oldname)

Newbk.Close savechanges:=False

End With

"bigjim" wrote:

I am using Excel 2003. I have a workbook named Main.xls I have a
worksheet in Main.xls named Ticket Cell j8 of Ticket contains a
ticket number such as NT0104, Cell b8 in ticket contains a co. name such
as Exxon, and cell b200 in ticket contains a dir path such as
c:\2009\Feb\ . I want to save the workbook main.xls to the new name
(in this case NT0104Exxon.xls) to the specified dir path (in this case
c:\2009\Feb) and then I want to keep the original workbook, Main.xls open.
When I run the following code, it saves NT0104Exxon.xls to My documents
instead of to c:\2009\Feb and then it closes the workbook. I would
appreciate any help on what I am doing wrong.
Here's the code:

rem sitting up variable that will determine where the files will be saved.

Dim strappend As String
Dim strpath As String
Dim str3 As String




Sheets("ticket").Select

strappend = ActiveSheet.Range("j8").Value
strpath = ActiveSheet.Range("b200").Value
str3 = ActiveSheet.Range("c8").Value

Rem Setting fsavename to directory and file
fsavename = strpth & strappend & str3 & ".xls"

Rem Saving the file fsavename to the designated directory

ThisWorkbook.SaveAs Filename:=fsavename

Rem this keeps the main workbook open
ActiveWorkbook.Close False
end sub

Thanks in advance for the help

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Saving a workbook

Thanks a bunch. That fixed the problem of the workbook staying open real
nice. The only problem is, it still saved it to My documents instead of to
c:\2009\Feb\. Do you have any idea what might be causing that?

"Joel" wrote:

try this code


oldname = ThisWorkbook.FullName

Dim strappend As String
Dim strpath As String
Dim str3 As String

With ThisWorkbook.Sheets("ticket")
oldname = ThisWorkbook.FullName

strappend = .Range("j8").Value
strpath = .Range("b200").Value
str3 = .Range("c8").Value

Rem Setting fsavename to directory and file
fsavename = strpth & strappend & str3 & ".xls"

Rem Saving the file fsavename to the designated directory

ThisWorkbook.SaveAs Filename:=fsavename

Rem this keeps the main workbook open
Set Newbk = ActiveWorkbook

Set Oldbk = Workbooks.Open(Filename:=oldname)

Newbk.Close savechanges:=False

End With

"bigjim" wrote:

I am using Excel 2003. I have a workbook named Main.xls I have a
worksheet in Main.xls named Ticket Cell j8 of Ticket contains a
ticket number such as NT0104, Cell b8 in ticket contains a co. name such
as Exxon, and cell b200 in ticket contains a dir path such as
c:\2009\Feb\ . I want to save the workbook main.xls to the new name
(in this case NT0104Exxon.xls) to the specified dir path (in this case
c:\2009\Feb) and then I want to keep the original workbook, Main.xls open.
When I run the following code, it saves NT0104Exxon.xls to My documents
instead of to c:\2009\Feb and then it closes the workbook. I would
appreciate any help on what I am doing wrong.
Here's the code:

rem sitting up variable that will determine where the files will be saved.

Dim strappend As String
Dim strpath As String
Dim str3 As String




Sheets("ticket").Select

strappend = ActiveSheet.Range("j8").Value
strpath = ActiveSheet.Range("b200").Value
str3 = ActiveSheet.Range("c8").Value

Rem Setting fsavename to directory and file
fsavename = strpth & strappend & str3 & ".xls"

Rem Saving the file fsavename to the designated directory

ThisWorkbook.SaveAs Filename:=fsavename

Rem this keeps the main workbook open
ActiveWorkbook.Close False
end sub

Thanks in advance for the help

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Saving a workbook

You've got to watch your typing.

Do you mean C8 or B8 for the cell with the company name?

You used strPath to get the path, but then used strPth in the concatenated
string.

There's a .savecopyas that allows you to save a copy of the current file as a
new name.

Option Explicit
Sub testme()
Dim strappend As String
Dim strpath As String
Dim str3 As String
Dim fSaveName As String

With Worksheets("ticket")
strappend = .Range("j8").Value 'nt0104
strpath = .Range("b200").Value 'c:\20009\feb
'b8 or c8????
str3 = .Range("c8").Value 'Exxon
End With

'setting fsavename to directory and file
fSaveName = strpath & strappend & str3 & ".xls"

'Saving the file fsavename to the designated directory
ThisWorkbook.SaveCopyAs Filename:=fSaveName

End Sub

(Compiled, but untested)


bigjim wrote:

I am using Excel 2003. I have a workbook named Main.xls I have a
worksheet in Main.xls named Ticket Cell j8 of Ticket contains a
ticket number such as NT0104, Cell b8 in ticket contains a co. name such
as Exxon, and cell b200 in ticket contains a dir path such as
c:\2009\Feb\ . I want to save the workbook main.xls to the new name
(in this case NT0104Exxon.xls) to the specified dir path (in this case
c:\2009\Feb) and then I want to keep the original workbook, Main.xls open.
When I run the following code, it saves NT0104Exxon.xls to My documents
instead of to c:\2009\Feb and then it closes the workbook. I would
appreciate any help on what I am doing wrong.
Here's the code:

rem sitting up variable that will determine where the files will be saved.

Dim strappend As String
Dim strpath As String
Dim str3 As String


Sheets("ticket").Select

strappend = ActiveSheet.Range("j8").Value
strpath = ActiveSheet.Range("b200").Value
str3 = ActiveSheet.Range("c8").Value

Rem Setting fsavename to directory and file
fsavename = strpth & strappend & str3 & ".xls"

Rem Saving the file fsavename to the designated directory

ThisWorkbook.SaveAs Filename:=fsavename

Rem this keeps the main workbook open
ActiveWorkbook.Close False
end sub

Thanks in advance for the help


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 67
Default Saving a workbook

Thank you, I feel like an idiot. I worked that for hours and didn't catch
the typo. Thanks for finding it and for the advise.

Jim Ford

"Dave Peterson" wrote:

You've got to watch your typing.

Do you mean C8 or B8 for the cell with the company name?

You used strPath to get the path, but then used strPth in the concatenated
string.

There's a .savecopyas that allows you to save a copy of the current file as a
new name.

Option Explicit
Sub testme()
Dim strappend As String
Dim strpath As String
Dim str3 As String
Dim fSaveName As String

With Worksheets("ticket")
strappend = .Range("j8").Value 'nt0104
strpath = .Range("b200").Value 'c:\20009\feb
'b8 or c8????
str3 = .Range("c8").Value 'Exxon
End With

'setting fsavename to directory and file
fSaveName = strpath & strappend & str3 & ".xls"

'Saving the file fsavename to the designated directory
ThisWorkbook.SaveCopyAs Filename:=fSaveName

End Sub

(Compiled, but untested)


bigjim wrote:

I am using Excel 2003. I have a workbook named Main.xls I have a
worksheet in Main.xls named Ticket Cell j8 of Ticket contains a
ticket number such as NT0104, Cell b8 in ticket contains a co. name such
as Exxon, and cell b200 in ticket contains a dir path such as
c:\2009\Feb\ . I want to save the workbook main.xls to the new name
(in this case NT0104Exxon.xls) to the specified dir path (in this case
c:\2009\Feb) and then I want to keep the original workbook, Main.xls open.
When I run the following code, it saves NT0104Exxon.xls to My documents
instead of to c:\2009\Feb and then it closes the workbook. I would
appreciate any help on what I am doing wrong.
Here's the code:

rem sitting up variable that will determine where the files will be saved.

Dim strappend As String
Dim strpath As String
Dim str3 As String


Sheets("ticket").Select

strappend = ActiveSheet.Range("j8").Value
strpath = ActiveSheet.Range("b200").Value
str3 = ActiveSheet.Range("c8").Value

Rem Setting fsavename to directory and file
fsavename = strpth & strappend & str3 & ".xls"

Rem Saving the file fsavename to the designated directory

ThisWorkbook.SaveAs Filename:=fsavename

Rem this keeps the main workbook open
ActiveWorkbook.Close False
end sub

Thanks in advance for the help


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Saving a workbook

Addin
Option Explicit
to the top of each module may make it seem like more work, but it would have
saved a little time for you.

bigjim wrote:

Thank you, I feel like an idiot. I worked that for hours and didn't catch
the typo. Thanks for finding it and for the advise.

Jim Ford

"Dave Peterson" wrote:

You've got to watch your typing.

Do you mean C8 or B8 for the cell with the company name?

You used strPath to get the path, but then used strPth in the concatenated
string.

There's a .savecopyas that allows you to save a copy of the current file as a
new name.

Option Explicit
Sub testme()
Dim strappend As String
Dim strpath As String
Dim str3 As String
Dim fSaveName As String

With Worksheets("ticket")
strappend = .Range("j8").Value 'nt0104
strpath = .Range("b200").Value 'c:\20009\feb
'b8 or c8????
str3 = .Range("c8").Value 'Exxon
End With

'setting fsavename to directory and file
fSaveName = strpath & strappend & str3 & ".xls"

'Saving the file fsavename to the designated directory
ThisWorkbook.SaveCopyAs Filename:=fSaveName

End Sub

(Compiled, but untested)


bigjim wrote:

I am using Excel 2003. I have a workbook named Main.xls I have a
worksheet in Main.xls named Ticket Cell j8 of Ticket contains a
ticket number such as NT0104, Cell b8 in ticket contains a co. name such
as Exxon, and cell b200 in ticket contains a dir path such as
c:\2009\Feb\ . I want to save the workbook main.xls to the new name
(in this case NT0104Exxon.xls) to the specified dir path (in this case
c:\2009\Feb) and then I want to keep the original workbook, Main.xls open.
When I run the following code, it saves NT0104Exxon.xls to My documents
instead of to c:\2009\Feb and then it closes the workbook. I would
appreciate any help on what I am doing wrong.
Here's the code:

rem sitting up variable that will determine where the files will be saved.

Dim strappend As String
Dim strpath As String
Dim str3 As String


Sheets("ticket").Select

strappend = ActiveSheet.Range("j8").Value
strpath = ActiveSheet.Range("b200").Value
str3 = ActiveSheet.Range("c8").Value

Rem Setting fsavename to directory and file
fsavename = strpth & strappend & str3 & ".xls"

Rem Saving the file fsavename to the designated directory

ThisWorkbook.SaveAs Filename:=fsavename

Rem this keeps the main workbook open
ActiveWorkbook.Close False
end sub

Thanks in advance for the help


--

Dave Peterson


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Saving a workbook

AddinG (with a G!).

Dave Peterson wrote:

Addin
Option Explicit
to the top of each module may make it seem like more work, but it would have
saved a little time for you.

bigjim wrote:

Thank you, I feel like an idiot. I worked that for hours and didn't catch
the typo. Thanks for finding it and for the advise.

Jim Ford

"Dave Peterson" wrote:

You've got to watch your typing.

Do you mean C8 or B8 for the cell with the company name?

You used strPath to get the path, but then used strPth in the concatenated
string.

There's a .savecopyas that allows you to save a copy of the current file as a
new name.

Option Explicit
Sub testme()
Dim strappend As String
Dim strpath As String
Dim str3 As String
Dim fSaveName As String

With Worksheets("ticket")
strappend = .Range("j8").Value 'nt0104
strpath = .Range("b200").Value 'c:\20009\feb
'b8 or c8????
str3 = .Range("c8").Value 'Exxon
End With

'setting fsavename to directory and file
fSaveName = strpath & strappend & str3 & ".xls"

'Saving the file fsavename to the designated directory
ThisWorkbook.SaveCopyAs Filename:=fSaveName

End Sub

(Compiled, but untested)


bigjim wrote:

I am using Excel 2003. I have a workbook named Main.xls I have a
worksheet in Main.xls named Ticket Cell j8 of Ticket contains a
ticket number such as NT0104, Cell b8 in ticket contains a co. name such
as Exxon, and cell b200 in ticket contains a dir path such as
c:\2009\Feb\ . I want to save the workbook main.xls to the new name
(in this case NT0104Exxon.xls) to the specified dir path (in this case
c:\2009\Feb) and then I want to keep the original workbook, Main.xls open.
When I run the following code, it saves NT0104Exxon.xls to My documents
instead of to c:\2009\Feb and then it closes the workbook. I would
appreciate any help on what I am doing wrong.
Here's the code:

rem sitting up variable that will determine where the files will be saved.

Dim strappend As String
Dim strpath As String
Dim str3 As String


Sheets("ticket").Select

strappend = ActiveSheet.Range("j8").Value
strpath = ActiveSheet.Range("b200").Value
str3 = ActiveSheet.Range("c8").Value

Rem Setting fsavename to directory and file
fsavename = strpth & strappend & str3 & ".xls"

Rem Saving the file fsavename to the designated directory

ThisWorkbook.SaveAs Filename:=fsavename

Rem this keeps the main workbook open
ActiveWorkbook.Close False
end sub

Thanks in advance for the help

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
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
saving 3 worksheets in a workbook to a separte workbook bigjim Excel Programming 6 November 5th 08 10:12 PM
Color Changes When Saving 2007 Workbook as 97 - 2003 Workbook Don Excel Discussion (Misc queries) 0 April 20th 08 04:51 AM
Saving Workbook Jeff Excel Discussion (Misc queries) 1 March 30th 07 07:57 PM
Saving a sheet in a workbook as .csv but not changing workbook name gloryofbach[_4_] Excel Programming 3 October 30th 05 08:50 PM
Saving a Workbook: Forcing User to Rename before Saving Rollin_Again[_6_] Excel Programming 5 April 16th 04 02:54 PM


All times are GMT +1. The time now is 10:23 PM.

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"