Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 683
Default Help with Workbook name change on update

Can anyone help me with this. I am not exactly sure what Dave Peterson means.

Q: Is the activeworkbook the same as the workbook that was opened?
A: Yes, but when the Workbook is opened it has one file name, but as soon as
you update it and save it the name changes. Then when you try and re-update
it the new name is not found, so I get the run Time Error.

Not exactly sure what you mean:

If yes, then declare the bk variable in a General module and make it public.

Public bk as workbook

(Remove the dim statement in the open procedure.)

Then use the bk variable to saveas

bk.saveas

And use bk as object to represent that workbook--no matter what the name is.

What's happening is when I save the workbook to a different name, because it
auto assigns the file name to according to the information on the User form.

The Workbook changes from the name "Master Engineering Spec.xlsm" to the
following.
strFile = "SPEC " & CLLI_Code_1.Value _
& Space(1) & TEO_No_1.Value _
& Space(1) & CES_No_1.Value _
& Space(1) & TEO_Appx_No_2.Value

I need help in changing the code so that it will recognize the new file
name. I posted all the code in my prior post on 1/7/2010 "Run Time Error on
File Name".

If you need me to repost the code let me know.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Help with Workbook name change on update

If you have not already tried this modified version, then try it and see if
you still get the Subscript out of Range message.

Private Sub Save_Engineering_Spec_11_Click()

Dim strFile As String
Dim fileSaveName As Variant
Dim myMsg As String

strFile = "SPEC " & CLLI_Code_1.Value _
& Space(1) & TEO_No_1.Value _
& Space(1) & CES_No_1.Value _
& Space(1) & TEO_Appx_No_2.Value

fileSaveName = Application.GetSaveAsFilename _
(InitialFileName:=strFile, _
fileFilter:="Excel Macro-Enabled Workbook(*.xlsm),(*.xlsm")

If fileSaveName < False Then
ActiveWorkbook.SaveAs Filename:= _
fileSaveName, _
FileFormat:=xlOpenXMLWorkbookMacroEnabled, _
CreateBackup:=False
Workbooks.Open ("Master Engineering Spec.xlsm")

Else
MsgBox prompt:=Engineer_2.Value & vbLf & "You canceled saving the
Engineering Spec." & vbCrLf & _
"Engineering Spec was not Saved.", _
Title:="C.E.S."
End If
End Sub

I added a line of code to re-open the Master Engineering Spec file. That is
the one that is causing the error when you try to correct an input error,
because it goes away as soon as you execute the SaveAs. Try doing the
corrective update process using this version and see if it still errors out.
If it does you might have to unload the UserForm and and re-load it.

With regards to Dave's suggestion about the Public variable, I do not
believe he was aware that you are saving the form data in the Master
Engineering Spec file. He was attempting to allow you to use the same
variable for different workbooks as you open them. That would probably
prevent the error message, but not cure the logic problem. You would open a
workbook but not necessarily have access to your previous form data.




"Brian" wrote in message
...
Can anyone help me with this. I am not exactly sure what Dave Peterson
means.

Q: Is the activeworkbook the same as the workbook that was opened?
A: Yes, but when the Workbook is opened it has one file name, but as soon
as
you update it and save it the name changes. Then when you try and
re-update
it the new name is not found, so I get the run Time Error.

Not exactly sure what you mean:

If yes, then declare the bk variable in a General module and make it
public.

Public bk as workbook

(Remove the dim statement in the open procedure.)

Then use the bk variable to saveas

bk.saveas

And use bk as object to represent that workbook--no matter what the name
is.

What's happening is when I save the workbook to a different name, because
it
auto assigns the file name to according to the information on the User
form.

The Workbook changes from the name "Master Engineering Spec.xlsm" to the
following.
strFile = "SPEC " & CLLI_Code_1.Value _
& Space(1) & TEO_No_1.Value _
& Space(1) & CES_No_1.Value _
& Space(1) & TEO_Appx_No_2.Value

I need help in changing the code so that it will recognize the new file
name. I posted all the code in my prior post on 1/7/2010 "Run Time Error
on
File Name".

If you need me to repost the code let me know.



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
Update Personal Workbook Macros when Workbook is opened. RyanH Excel Programming 4 August 22nd 08 04:57 PM
workbook change and update Sofia Grave Excel Worksheet Functions 0 February 27th 08 08:46 AM
Can one workbook/sheet update another workbook? jtpryan Excel Discussion (Misc queries) 0 November 13th 07 03:56 PM
Change workbook sheet reference using cell A1 to change a vairable Reed Excel Worksheet Functions 4 January 20th 05 07:15 PM
Update on change myleslawrence Excel Programming 5 January 18th 05 12:27 AM


All times are GMT +1. The time now is 04:30 AM.

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"