Perksy_no1
Well-known Member
- Joined
- Oct 27, 2011
- Messages
- 598
- Office Version
- 365
- Platform
- Windows
Hi there,
The other day I found the following code on this site which I've but in ThisWork Workbook_Open module to prompt the user to save the file as some else before they start using it, which is working fine.
I've then tryed to put it in another work book and im now coming up with the error "Complie Error: Invalid use of Me keyword"
I've tried putting this code in a standard module as per below
Not sure where im going wrong so any help would be much appreciated
Thanks in advance
Mark
[/code]
The other day I found the following code on this site which I've but in ThisWork Workbook_Open module to prompt the user to save the file as some else before they start using it, which is working fine.
Code:
Dim fNameAndPath As Variant
fNameAndPath = Application.GetSaveAsFilename(InitialFileName:="", FileFilter:="Excel Files (*.XLS), *.XLS", Title:="Save As")
If fNameAndPath = False Then Exit Sub
Me.SaveAs Filename:=fNameAndPath
I've then tryed to put it in another work book and im now coming up with the error "Complie Error: Invalid use of Me keyword"
I've tried putting this code in a standard module as per below
Code:
Sub MoveContainerKeyedSheet()
Set ThisWkb = ThisWorkbook
Set NewBook = Workbooks.Add
ThisWkb.Sheets("Containers").Copy Before:=NewBook.Sheets(1)
With NewBook
On Error Resume Next
.Sheets("Sheet1").Delete
.Sheets("Sheet2").Delete
.Sheets("Sheet3").Delete
.Sheets("Sheet4").Delete
.Sheets("Containers").Select
ActiveSheet.Buttons.Delete
End With
Dim fNameAndPath As Variant
fNameAndPath = Application.GetSaveAsFilename(InitialFileName:="", FileFilter:="Excel Files (*.XLS), *.XLS", Title:="Save As")
If fNameAndPath = False Then Exit Sub
Me.SaveAs fileName:=fNameAndPath
End Sub
Not sure where im going wrong so any help would be much appreciated
Thanks in advance
Mark
[/code]