Hi!
I have a somewhat frustrating problem with my Excel 2007 vba code.
I think it might be a weird memory issue.
Here is what I do and what happens:
I have a procedure that copys a template worksheet within the workbook using "Copy After", then renames the copy and fills in some data.
Now there is a button on that copy which triggers a procedure that copys the activeSheet (the copy of the template, you remember? ) into a new workbook saves the new file and immediately closes the new workbook.
Code:
Everything works perfectly fine so far.
But if I open the newly created file with the one sheet I copied while my "main" workbook is still open, I cant execute the procedure which is supposed to copy the template sheet anymore.
It's really weird and not so easy to explain, but even if I close all excel instances and re-open both files and just click the "copy template procedure" it errors out with an "automation error". The exact line is
Even when I open my seperate workbook and close it again and try the procedure after that the error occures.
I hope I made myself understood and provided enough information. Feel free to ask for more code or whatever question there might be
Thanks a lot in advance
So long Vincent
I have a somewhat frustrating problem with my Excel 2007 vba code.
I think it might be a weird memory issue.
Here is what I do and what happens:
I have a procedure that copys a template worksheet within the workbook using "Copy After", then renames the copy and fills in some data.
Now there is a button on that copy which triggers a procedure that copys the activeSheet (the copy of the template, you remember? ) into a new workbook saves the new file and immediately closes the new workbook.
Code:
PHP:
Sub SaveAsWorkbook()
Application.ScreenUpdating = False
Path = ActiveWorkbook.Path
ActiveSheet.Copy
Range("AK2").Clear
ActiveSheet.Buttons(1).Delete
ActiveWorkbook.SaveAs Filename:=Path & "\Doku_" & Replace(Range("D6").Value, ", ", "_") & "_" & Replace(Range("D8").Value, " ", "_") & ".xlsm", FileFormat:=52
ActiveWorkbook.Close
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
But if I open the newly created file with the one sheet I copied while my "main" workbook is still open, I cant execute the procedure which is supposed to copy the template sheet anymore.
It's really weird and not so easy to explain, but even if I close all excel instances and re-open both files and just click the "copy template procedure" it errors out with an "automation error". The exact line is
PHP:
ActiveWorkbook.Worksheets("Sheet_Template").Copy After:=ActiveWorkbook.Worksheets("Sheet_Template")
I hope I made myself understood and provided enough information. Feel free to ask for more code or whatever question there might be
Thanks a lot in advance
So long Vincent