excel - Temp file trying to save to non-existing location -
i having issues below module. well, colleagues , don't know how resolve. when run sub myself, works fine, of colleagues getting error. looks though it's trying save temp file folder doesn't exist.
is there way can amend code save temp file specific location?
thank you.
sub email_sheet() dim oapp object dim omail object dim lworkbook workbook dim lfilename string activesheet.calculate subjectpanel = inputbox("please enter time") & " text" 'turn off screen updating application.screenupdating = false 'copy active worksheet , save temporary workbook activesheet.copy set lworkbook = activeworkbook 'create temporary file lfilename = lworkbook.worksheets(1).name on error resume next 'delete file if exists kill lfilename on error goto 0 'save temporary file lworkbook.saveas filename:=lfilename 'create outlook object , new mail message set oapp = createobject("outlook.application") set omail = oapp.createitem(0) omail .sentonbehalfofname = "" .to = "" & _ "address" .cc = "" & _ "other address" .subject = subjectpanel .body = "hello all," & vbnewline & vbnewline & _ "body" & vbnewline & vbnewline & _ "thank you." .attachments.add lworkbook.fullname .display end 'delete temporary file , close temporary workbook lworkbook.changefileaccess mode:=xlreadonly kill lworkbook.fullname lworkbook.close savechanges:=false 'turn on screen updating application.screenupdating = true set omail = nothing set oapp = nothing end sub
after line
lworkbook.saveas filename:=lfilename
put line:
debug.print lworkbook.fullname
now when colleague runs it, ask them open vba editor first, , ask them make sure immediate window shown. them run it, , ask them shown in immediate window after error. (it useful if actual error was, , in code stops at, i'll make assumptions that!).
when run code line, on new workbook, immediate window shows c:\users\simon\documents\sheet1.xlsx
. , saves temporary file name , folder.
if can ask colleague theirs says, can find out if folder perhaps not allow write permission (ask them try save folder).
if problem (if have assumed correctly!), need change saveas
line add path have permission. example:
lworkbook.saveas filename:= "c:\users\xxx\documents\" & lfilename
Comments
Post a Comment