Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro won't open original file?


The last instruction of the macro below is to open the original file,
but it fails to do so.
I have no idea why?
As always, this forums help is greatly appreciated.

[Begin macro]
Sub Save_As()
'
' Save_As Macro
' Macro recorded 1/3/2006 by rstanich
'
' Keyboard Shortcut: Ctrl+x
'
Dim sDcode As String 'Date Code as String
Dim sScode As String 'Serial Number Code as String
Dim sFname1 As String 'File Name of Original file as String
Dim vFname2 As Variant 'File Name of New file as Variable

Dim bOkToSave As Boolean 'True or False
Dim sPath As String 'Path variable

sPath = ThisWorkbook.path 'Get path of file

ThisWorkbook.Activate
Worksheets("Sheet2").Select 'Select Work Sheet 2
sDcode = Range("D2").Value 'Select Cell D2 on Sheet 2
sScode = Range("C2").Value 'Select Cell C2 on Sheet 2
sFname1 = sPath & "\" & "0020-48183-fir_Cal-Precision.xls" 'Set File
Name of Original file
vFname2 = sPath & "\" & "0020-48183-fir_Cal-Precision-" & sDcode & "-"
& sScode & ".xls" 'Set new file name

'Create new file name begin
'Check if exists, exit if exists
ActiveWorkbook.SaveAs Filename:=vFname2, FileFormat:=xlNormal
'Self checks for existing file
ActiveWorkbook.Close SaveChanges:=False 'Close new file
'Open original file
Workbooks.Open Filename:=sFname1

End Sub
[End Macro]


--
Rick_Stanich

I am me
------------------------------------------------------------------------
Rick_Stanich's Profile: http://www.excelforum.com/member.php...o&userid=28957
View this thread: http://www.excelforum.com/showthread...hreadid=512358

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro won't open original file?


Found one solution, see code below.

sFname = sPath & "\" & "0020-48183-fir_Cal-Precision.xls" 'Set File
Name of Original file
vFname = sPath & "\" & "0020-48183-fir_Cal-Precision-" & sDcode & "-" &
sScode & ".xls" 'Set new file name
'MsgBox sFname & " " & "Original file name" 'for testing
'MsgBox vFname & " " & "New file name" 'for testing
'Create new file name
'Check if exists, exit if exists 'need code
ActiveWorkbook.SaveCopyAs vFname 'NEW CODE
'MsgBox sFname & " " & "Original file should be open" 'for testing

This wasn't a matter of a macro not opening the original file, but the
macro closing files that did not need closing.


--
Rick_Stanich

I am me
------------------------------------------------------------------------
Rick_Stanich's Profile: http://www.excelforum.com/member.php...o&userid=28957
View this thread: http://www.excelforum.com/showthread...hreadid=512358

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
Open a file do a macro ( made) and open next succesive file SVTman74 Excel Programming 5 April 21st 06 10:14 PM
Do Until macro that renames workbooks and keeps the original workbook open [email protected] Excel Programming 2 February 13th 06 01:42 AM
Why is my macro looking for the original file I created it on? Brett Smith[_2_] Excel Programming 1 January 3rd 06 11:02 PM
Auto save replaced my original file and now I need the original? Hols Excel Discussion (Misc queries) 1 August 15th 05 10:34 PM
Macro to call a file that has a auto open macro in the file itself [email protected] Excel Programming 1 August 5th 05 06:39 AM


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