Run time error 462 Access VBA using Excel -


i run time error when trying open/manipulate excel files using access vba. error

"run-time error '462': remote server machine not exist or unavailable

what frustrating error occurs files , not others , in different instances. here code, error occurs @ workbooks.open(spath) line:

    docmd.setwarnings false  dim oexcel new excel.application dim owb workbook dim ows worksheet  set oexcel = excel.application set owb = oexcel.workbooks.open(spath) set ows = owb.sheets(1)  oexcel.visible = false      if fgetfilename(spath) = "file_name1.xlsx"         'oexcel.visible = false         ows.range("aw1").value = "text1"         ows.range("ax1").value = "text2"         ows.range("ay1").value = "text3"     end if  owb.save debug.print "amended " & spath  owb.close false set owb = nothing  oexcel.quit set oexcel = nothing  docmd.setwarnings true 

after bit of research online, i've found document gives overview of error: https://anictteacher.files.wordpress.com/2011/11/vba-error-462-explained-and-resolved.pdf

using logic document, error that:

object has not been qualified reference office object in every case

however, amended row error occurs reference excel object (set owb = oexcel.workbooks.open(spath)). have tried declaring dimensions objects , put reference oexcel in every mention of workbook/sheet. ideas? spath need better qualified?

you declare oexcel new excel.application:

dim oexcel new excel.application 

that means later in code, set oexcel = excel.application not useful ... because oexcel reference excel.application. add in msgbox demonstrate oexcel @ point ...

msgbox "typename(oexcel): " & typename(oexcel) 'set oexcel = excel.application 

consider different approach excel object variable. test stripped down procedure (the purpose see whether eliminates current error):

dim oexcel excel.application dim owb excel.workbook  docmd.setwarnings true  msgbox "typename(oexcel): " & typename(oexcel) set oexcel = new excel.application msgbox "typename(oexcel): " & typename(oexcel) set owb = oexcel.workbooks.open(spath) owb.close false set owb = nothing oexcel.quit set oexcel = nothing 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -