Run time error 91

Garners Workshop

New member
Local time
Today, 02:18
Joined
Jun 4, 2014
Messages
4
Hi I have built a working database in Access 2007 not using SQL server.
I have upgraded to Access 2013 Office

Tis code to create and save worked now makes error 91 please help.


Call Shell("explorer.exe " & "C:\Allfiles\Job Template\Job Template.xlsm", vbNormalFocus)
Dim xlBook As Object
Dim xlApp As Object

Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Application.activeworkbook

xlApp.Application.activeworkbook.saveas ("C:\Allfiles\Jobs\") & [Job No] & (".") & [Job Name] & ("\Costs") & (" ") & [Job Name]
MsgBox "Work Book saved!"



Resulting error

Runtime error '91'
object variable or with block variable not set
 
Hello Garners Workshop, Welcome to AWF :)

Can you please highlight which section of the code you are getting the error?
 
Hi Paul I think this line of code is causing the error

xlApp.Application.activeworkbook.saveas ("C:\Allfiles\Jobs\") & [Job No] & (".") & [Job Name] & ("\Costs") & (" ") & [Job Name]


Thanks Nick.
 
Why all the parentheses? And there is no file extension.

xlApp.Application.ActiveWorkbook.SaveAs "C:\Allfiles\Jobs\" & [Job No] & "." & [Job Name] & "\Costs " & [Job Name] & ".xls"
 
Hi Paul I have followed your suggestions but error remains (Thanks good suggestions I will remember these ) Any other Ideas ? Nick.
 
Are you sure that the [Job No] and [Job Name] have values? Did you try some debugging?
 

Users who are viewing this thread

Back
Top Bottom