Hi,
I am trying to save an excel file with access vb script code.
The code I am using works the first time around but when I run it again it gives me an error:
Run Time Error 91
Object variable or with block variable npt set.
Here is the code:
Set r1 = wbk.Sheets("CTAS Total (2)").Range("A1:S65")
r1.Copy
wbk.Sheets("CTAS Total (2)").Select
r1.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
wbk.Sheets("CTAS Total (2)").Copy
This is where I get the error:
ActiveWorkbook.SaveAs FileName:= _
"J:\cag\Network Information INFO,CSC_IVR\FISCAL 2008\New IBTM Report\Branch Transit Report\Report\Transit " & Forms!CTAS_BRANCH_REPORT!Text0 & ".xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
wbk.Close ("CTAS BRANCH REPORT")
appExcel.Quit
I would really appreciate if any one can help me with this.
P.S. I had posted this request before but I can not find the thread. I apologize for posting it again.
Thank you for all your help.
I am trying to save an excel file with access vb script code.
The code I am using works the first time around but when I run it again it gives me an error:
Run Time Error 91
Object variable or with block variable npt set.
Here is the code:
Set r1 = wbk.Sheets("CTAS Total (2)").Range("A1:S65")
r1.Copy
wbk.Sheets("CTAS Total (2)").Select
r1.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
wbk.Sheets("CTAS Total (2)").Copy
This is where I get the error:
ActiveWorkbook.SaveAs FileName:= _
"J:\cag\Network Information INFO,CSC_IVR\FISCAL 2008\New IBTM Report\Branch Transit Report\Report\Transit " & Forms!CTAS_BRANCH_REPORT!Text0 & ".xls" _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
wbk.Close ("CTAS BRANCH REPORT")
appExcel.Quit
I would really appreciate if any one can help me with this.
P.S. I had posted this request before but I can not find the thread. I apologize for posting it again.
Thank you for all your help.