Hi Polar
The new sheet links its values to the original sheet. You can use
PasteSpecial to transform all formulas in the new sheet into values, and
then there will be no link to the original workbook.
Dim invName As String
Dim MyPath As String
MyPath = "C:\Users\Justin\Documents\Razza Jam\"
With Sheets("Invoice2")
invName = .Range("L4").Value & ".xls"
.Copy
'Will ignore the error
On Error Resume Next
ActiveSheet.UsedRange.Copy
ActiveSheet.Range("A1").PasteSpecial Paste:=xlPasteValues
ActiveWorkbook.SaveAs Filename:=MyPath & invName
On Error GoTo 0
'Will close without another alert message
Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True
End With
Hopes this helps.
....
Per
"polar" skrev i meddelelsen
...
Hi Everybody,
I have an excel workbook with code that generates a separate workbook
with a unique file name.
This is my code to create a new workbook:
Code:
--------------------
With Sheets("Invoice2")
Dim invName As String
Sheets("Invoice2").Select
invName = Range("L4").Value & ".xls"
Sheets("Invoice2").Copy
ChDir "C:\Users\Justin\Documents\Razza Jam"
'Will ignore the error
On Error Resume Next
ActiveWorkbook.SaveAs Filename:=invName
On Error GoTo 0
'Will close without another alert message
Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True
End With
End Sub
--------------------
Basically, for the Invoice Worksheet, when a button is clicked a
separate workbook is generated with just the current invoice worksheet.
Everything works fine but when I open the newly created file, I get
prompted with this message:
"This workbook contains links to other data sources:
* If you update the links, Excel will attempt to retrieve the latest
data.
* If you don't update the links, Excel will use the previous
information."
Then at the bottom of the warning box there is 'update' and 'don't
update' and 'help'.
Is there anyway to eliminate this message coming up each time I create
a new file? It's just something which is shared and to be honest I would
be happy if the opened file was read only.
Any help would be greatly appreciated.
Thank you.
Kind regards,
Polar
--
polar
------------------------------------------------------------------------
polar's Profile: http://www.thecodecage.com/forumz/member.php?userid=564
View this thread:
http://www.thecodecage.com/forumz/sh...d.php?t=120950