Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Need help with code to save/open

I have VBA code called "savetoron" in a spreadsheet (Max OSX, Excel
2004) which reads some data from certain cells and constructs a
filename, then saves that spreadsheet, with that filename, to a certain
location, and closes that file on the screen. It reads like this:

Sub savetoron()
fname = "(" & Range("B1") & ")" & Range("D1") & Range("H1") & "_" &
Range("T1") & ".xls"
pathname = "Volumes:ACSP:IDEACoordination:Funding Team:WEBSAS
Review:Ron Morgan:06-07:"
ActiveWorkbook.SaveAs Filename:=pathname & fname, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWorkbook.Close
End Sub

What I'm trying to do is modify this code so that it would not only
close the file, it would also open the original file called
"06-07main.xls"
which is on my desktop. I think that code should look like this:

Workbooks.Open Filename:= _
"Mac OS X HD:Users:rmorgan:Desktop:06-07main.xls"

The task I'm trying to facilitate: the user starts off with
06-07main.xls, which is a blank template spreadsheet. He fills it in
with some data, then hits a "Save" button/object which executes the
"savetoron" code above.

Then it re-opens a fresh copy of 06-07main.xls, he fills it in, hits
the save button, and it gets saved, closes, and another fresh one
opens, etc. etc.

I can NOT find a place to insert the Workbooks.Open code so it will
work. Can somebody help?

Thanks,
Ron M.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Need help with code to save/open

Sub savetoron()
fname = "(" & Range("B1") & ")" & Range("D1") & Range("H1") & "_" &
Range("T1") & ".xls"
pathname = "Volumes:ACSP:IDEACoordination:Funding Team:WEBSAS
Review:Ron Morgan:06-07:"
ActiveWorkbook.SaveAs Filename:=pathname & fname, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

Dim wb As New Workbook
Dim wb_old As New Workbook
Set wb_old = Application.ActiveWorkbook
Set wb = Application.Workbooks.Open("C:\book1.xls")
wb_old.Close

''''''''''''''''''''''ActiveWorkbook.Close 'Remove this
End Sub


hope this will help

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Need help with code to save/open

Sub savetoron()
fname = "(" & Range("B1") & ")" & Range("D1") & Range("H1") & "_" &
Range("T1") & ".xls"
pathname = "Volumes:ACSP:IDEACoordination:Funding Team:WEBSAS
Review:Ron Morgan:06-07:"
ActiveWorkbook.SaveAs Filename:=pathname & fname, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
set bk = ActiveWorkbook
Workbooks.Open Filename:= _
"Mac OS X HD:Users:rmorgan:Desktop:06-07main.xls"
bk.Close SaveChange:=False
End Sub


--
Regards,
Tom Ogilvy



wrote in message
oups.com...
I have VBA code called "savetoron" in a spreadsheet (Max OSX, Excel
2004) which reads some data from certain cells and constructs a
filename, then saves that spreadsheet, with that filename, to a certain
location, and closes that file on the screen. It reads like this:

Sub savetoron()
fname = "(" & Range("B1") & ")" & Range("D1") & Range("H1") & "_" &
Range("T1") & ".xls"
pathname = "Volumes:ACSP:IDEACoordination:Funding Team:WEBSAS
Review:Ron Morgan:06-07:"
ActiveWorkbook.SaveAs Filename:=pathname & fname, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWorkbook.Close
End Sub

What I'm trying to do is modify this code so that it would not only
close the file, it would also open the original file called
"06-07main.xls"
which is on my desktop. I think that code should look like this:

Workbooks.Open Filename:= _
"Mac OS X HD:Users:rmorgan:Desktop:06-07main.xls"

The task I'm trying to facilitate: the user starts off with
06-07main.xls, which is a blank template spreadsheet. He fills it in
with some data, then hits a "Save" button/object which executes the
"savetoron" code above.

Then it re-opens a fresh copy of 06-07main.xls, he fills it in, hits
the save button, and it gets saved, closes, and another fresh one
opens, etc. etc.

I can NOT find a place to insert the Workbooks.Open code so it will
work. Can somebody help?

Thanks,
Ron M.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Need help with code to save/open

Thanks. Arthur's worked, Tom's didn't.

Ron

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Need help with code to save/open

Sorry, but I am hard pressed to see a difference.

--
Regards,
Tom Ogilvy


wrote in message
oups.com...
Thanks. Arthur's worked, Tom's didn't.

Ron





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Need help with code to save/open

Tom: when I used yours, it produced an error - a 1040, I think - and in
the debugger, that last line, "bk.Close SaveChange:=False":" was
highlighted.

Ron

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need help with code to save/open


Hello it's simple to open a form you would use the name of the form:
Example
MyForm.Show

to Save the Change to the file you would use the code like this:
Example
Use the name of your time sheet for instance say your time sheet is
called,
myitem.

myitem.Save

to specify where you want to save this work sheet you will need to use
an object called a browser object. This object could be used to specify
where you want to save this item or work.


--
shawnRheal
------------------------------------------------------------------------
shawnRheal's Profile: http://www.excelforum.com/member.php...o&userid=34870
View this thread: http://www.excelforum.com/showthread...hreadid=545726

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Need help with code to save/open

Looks like a typo

bk.Close SaveChange:=False
should be

bk.Close SaveChanges:=False

--
Regards,
Tom Ogilvy

wrote in message
oups.com...
Tom: when I used yours, it produced an error - a 1040, I think - and in
the debugger, that last line, "bk.Close SaveChange:=False":" was
highlighted.

Ron



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Need help with code to save/open

Thanks, Tom. I guess you're off the hook... (-; (-;

Ron

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
ON OPEN VBA Code input incorrectly now excel sheet wont open mmartin New Users to Excel 1 February 16th 11 11:33 PM
Code to Save As, then Open - can't figure it out! [email protected] Excel Discussion (Misc queries) 0 May 25th 06 09:18 PM
Totally Disabling (^ save ) (Save as) and Save Icon – Which code do I use: harpscardiff[_10_] Excel Programming 8 November 10th 05 12:24 PM
Placing a code before Save & Save As Alex Martinez Excel Programming 1 September 27th 05 06:35 AM
Code to open new workbook, prompt for 'save as' name. Mark Excel Programming 1 April 5th 05 10:49 PM


All times are GMT +1. The time now is 11:16 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"