vba - Shared Excel macro enabled workbook - Excel cannot access the file issue -


what want do.

send macro enabled excel document colleagues working macro opens save file dialog , generates csv.

what have done?

i have made vba-macro in excel 2013 , works fine on machine. however, when send macro enabled excel-sheet colleague gets:

microsoft office excel cannot access file 'path document on computer'. there several possible reasons:

  • the file name or path not exist.
  • the file being used program.
  • the workbook trying save has same name open workbook

my source:

sub convert2csv()     dim filename string     filename = "ordersedel_" & format(now, "yyyy-mm-dd hh mm") & ".csv"      application.filedialog(msofiledialogsaveas)             .title = "xxx"             .allowmultiselect = false             .initialfilename = filename             .filterindex = 15             result = .show             if (result <> 0)                 ' create file                 filename = trim(.selecteditems.item(1))                 fnum = freefile                 open filename output fnum                   ' write csv data form record set                 = 7 activesheet.usedrange.rows.count                     if ( _                         (not trim(cells(i, 1).value & vbnullstring) = vbnullstring or _                         not trim(cells(i, 3).value & vbnullstring) = vbnullstring) , _                         not trim(cells(i, 9).value & vbnullstring) = vbnullstring)                             'check ean (trim). if no ean bolist artnum                             if (trim(cells(i, 3).value & vbnullstring) = vbnullstring)                                 print #fnum, cells(i, 1).value & ";" & cells(i, 9).value                                 else                                 print #fnum, cells(i, 3).value & ";" & cells(i, 9).value                                 end if                     end if                 next                ' close file             close #fnum             end if       end  end sub 

screenshot of file xlsm

send code them insert macro run , see if same error. ran fine me (except define variables).

it copy of excel not set trust vba. (under settings.)


Comments

Popular posts from this blog

tcpdump - How to check if server received packet (acknowledged) -