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

Export with attachments #518

Closed
aulline13 opened this issue Jun 19, 2022 · 11 comments · Fixed by #522 or #531
Closed

Export with attachments #518

aulline13 opened this issue Jun 19, 2022 · 11 comments · Fixed by #522 or #531
Assignees
Labels
feature-request New feature or request released Available in a released installer

Comments

@aulline13
Copy link

aulline13 commented Jun 19, 2022

When exporting onenote page with attachments to docx, the attachment is saved in the same directory as the page itself, and the link to it is given. But if the user changes the directory of the attachment then the link will become broken until the user manually fixes it. It would be great if there was a way to avoid this problem. Probably it would be possible to:

  1. Add the option allowing to export the page with attachments providing the link to a relative, not absolute, path
  2. Add the option to export the attachment not as a file in the same directory but as a file in the exported docx itself. I use MS Word 2019, which allows the user to drag files into the docx and locate them there. Alternatively, the user can go to the Insert and choose "Object" to achieve the same goal (https://support.microsoft.com/en-us/office/embed-or-link-to-a-file-in-word-8d1a0ffd-956d-4368-887c-b374237b8d3a). This way the user can still open all the files right from the docs. It looks like this:

Files in docx

P.S. Thanks for fixing the issue of broken links with non-Unicode characters and for such a great add-in to OneNote :)

@stevencohn stevencohn added the feature-request New feature or request label Jun 20, 2022
@stevencohn
Copy link
Owner

MS Office attachments, whether in Word or Outlook or OneNote, are all absolute. I don't believe there is a way to add relative references. This is true for OLE embedded objects like you mention in option #2. These would be the same as the hyperlinks that OneMore adds to the docx file currently, but a little prettier.

@aulline13
Copy link
Author

I played around with the embedded objects I used to make the screenshot above and noticed that they can be accessed and edited even if I delete the initial file from my laptop. This is true if the user ticks "Display as icon" when inserting the object. So I think option 2 might be a workaround even given that all links are absolute. It might come in handy in case the user does not want to worry about links becoming broken due to possible changes in file paths in the future.
*Btw, I noticed I had pasted a wrong link in the first post, have just changed it.

@stevencohn
Copy link
Owner

There is an option to either embed the file as an object or link to the file. You've elected to embed the file. This means it is divorced from the source file and changes to either won't be reflected in the other.

So it was quite easy to embed or link to a file with an icon (already have a working prototype!) and I could add options to the Export dialog asking to either embed or link.

If it can't find an associated OLE automation application registered, it will revert to the hyperlinked absolute file as it does now.

@stevencohn stevencohn self-assigned this Jun 22, 2022
@stevencohn stevencohn added the developing Accepted and development is in progress label Jun 22, 2022
@stevencohn stevencohn linked a pull request Jun 22, 2022 that will close this issue
@stevencohn stevencohn reopened this Jun 22, 2022
@stevencohn stevencohn added next-release Addressed but not yet released and removed developing Accepted and development is in progress labels Jun 22, 2022
@aulline13
Copy link
Author

Great, I got it. Thank you!

@stevencohn stevencohn added released Available in a released installer and removed next-release Addressed but not yet released labels Jun 25, 2022
@aulline13
Copy link
Author

Here am I again... I gave it a try a couple of days ago, and everything was just right. However, recently I have completed the reinstallation of my OS (Win10) and reinstalled OneNote with OneMore, and since then it only rarely embeds files - mostly, there are absolute links instead (I am not sure if this reinstallation has something to do with it, it just seems strange to me given that before everything was ok). As it follows from your explanation, this happens when it can't find an associated OLE automation application registered. I wonder if there are certain instances that can prompt such behaviour.
OneNote: 2205 (15225.20288, click to run) 64x
OneMore: 4.18, 64x

@stevencohn
Copy link
Owner

Sorry you're having problems again. It does sound like your assessment is right. Do you have an app installed that opens these files by default?

I think it would be super annoying to prompt for every attachment that doesn't have a default app installed. Of course I could make that a preference but then again, why would you have attachments that you can't open?!?!

@aulline13
Copy link
Author

Yes, I have default apps for these files. I have just tried to export a page with files both with and without default apps and the result was the same, i.e. all these files were exported as absolute links.

@stevencohn
Copy link
Owner

What is the app?

@aulline13
Copy link
Author

Word, Excel, PowerPoint (defaults for docx, excel sheets, ppts, respectively) and tar.gz archive with no default app

@stevencohn
Copy link
Owner

I used a Windows API to discover the default registered app. Perhaps the API doesn't consider all configurations. I'll need to do some investigating but not sure I know how to reproduce it.

@stevencohn
Copy link
Owner

I figured out a better way to lookup the registered application. I'll add it to the next release.

@stevencohn stevencohn linked a pull request Jun 29, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request released Available in a released installer
Projects
None yet
2 participants