Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I turn off the delete_registry #1

Open
RE-Chief opened this issue Apr 20, 2020 · 3 comments
Open

Can I turn off the delete_registry #1

RE-Chief opened this issue Apr 20, 2020 · 3 comments

Comments

@RE-Chief
Copy link

Hi, I have alot of old xls files that need to be converted to xlsx and have used your function previously. The code I have written works on my machine at work but with working from home at the moment I am getting an error to do with deleting the a registry key and the code failts to convert my xls files. The error is:

reg delete HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Excel\Resiliency\StartupItems /f
ERROR: The system was unable to find the specified registry key or value.

I Have checked the registry and the Resiliency Key does not exist, which is obviously the reason for the error. Can you suggest a work around please?

Kind regards Charles

@mrustl
Copy link
Member

mrustl commented Apr 20, 2020

Hi,

you could try:

convert_xls_as_xlsx <- function(input_dir,
                                export_dir = tempdir(),
                                office_folder = safe_office_folder(),
                                delete_registry = FALSE,
                                dbg = TRUE) {
  input_dir <- normalizePath(input_dir)

  export_dir <- normalizePath(export_dir)

  pattern <- "\\.([xX][lL][sS])$"

  xls <- normalizePath(dir(
    input_dir, pattern,
    recursive = TRUE, full.names = TRUE
  ))

  xlsx <- gsub(input_dir, export_dir, xls, fixed = TRUE)

  xlsx <- gsub(pattern, ".xlsx", xlsx)

  fs::dir_create(path = normalizePath(dirname(xlsx)), recursive = TRUE)

  exe <- normalizePath(get_excelcnv_exe(office_folder))

  for (i in seq_along(xls)) {
    convert_xls_to_xlsx(exe, xls[i], xlsx[i], i, length(xls), dbg = dbg)

    if (delete_registry) delete_registry(office_folder, dbg = dbg)
  }
}

Just set the delete_registry argument to TRUE if deletion of registry entry is needed..

@RE-Chief
Copy link
Author

Thank you for your reply.

I have been trying to use convert_xls_as_xlsx: if I declare delete_registry = FALSE or TRUE I get an error message

convert_xls_as_xlsx(input_dir = wd,

  •                 export_dir = wd,
    
  •                 office_folder = "C:/Program Files/Microsoft Office/root/Office16", 
    
  •                 delete_registry = FALSE, 
    
  •                 dbg = TRUE)
    

Error in convert_xls_as_xlsx(input_dir = wd, export_dir = wd, office_folder = "C:/Program Files/Microsoft Office/root/Office16", :
unused argument (delete_registry = FALSE)

If I don't use the argument delete_registry I get the following

convert_xls_as_xlsx(input_dir = wd,

  •                 export_dir = wd,
    
  •                 office_folder = "C:/Program Files/Microsoft Office/root/Office16", 
    
  •                 dbg = TRUE)
    

Warning: recursive is deprecated, please use recurse instead

Converting xls to xlsx (1/16):
"C:\Program Files\Microsoft Office\root\Office16\excelcnv.exe" -oice "F:\aWorking\Aus native fish\Estuary Perch\OutputMS1\1.xls" "F:\aWorking\Aus native fish\Estuary Perch\OutputMS1\1.xlsx"

Deleting registry entry:
reg delete HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Excel\Resiliency\StartupItems /f
ERROR: The system was unable to find the specified registry key or value.

The code will cycle through my list of xls files and not convert any, after about 30 seconds the error message is delivered and the code moves on to the next file.

Kind regards Charles

@RE-Chief
Copy link
Author

I did as you suggested and created a new function with delete_registry=FALSE, it stopped the error that I was getting but the function is still not converting my files. Everything runs but nothing changes in my destination folder.

convert_xls_as_xlsx(input_dir = wd,
export_dir = wd,
office_folder = "C:/Program Files/Microsoft Office/root/Office16",
dbg = TRUE)
Warning: recursive is deprecated, please use recurse instead

Converting xls to xlsx (1/16):
"C:\Program Files\Microsoft Office\root\Office16\excelcnv.exe" -oice "F:\aWorking\Aus native fish\Estuary Perch\OutputMS1\1.xls" "F:\aWorking\Aus native fish\Estuary Perch\OutputMS1\1.xlsx"

Converting xls to xlsx (2/16):
"C:\Program Files\Microsoft Office\root\Office16\excelcnv.exe" -oice "F:\aWorking\Aus native fish\Estuary Perch\OutputMS1\2.xls" "F:\aWorking\Aus native fish\Estuary Perch\OutputMS1\2.xlsx"

Kind regards Charles

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants