Is there a way to view the contents of a Visual Basic file that has been formatted, after it has been imported into a Scrivener project? If the file is imported with a .txt extension then the file contents can be seen and edited but I was hoping to retain the .bas extension.
What is your ultimate goal?
Scrivenerâs native format is RTF, and thatâs the only format it knows how to edit. So no, thereâs no way to retain the extension for an editable file.
OTOH, if you export the file back out again, you can give the output document any extension you want.
If you only want to view the content of a .bas file and not edit it, shouldnât a QuickLook extension like PreviewCode do the trick?
The goal was (as always!) a little complicated. I have a Scrivener project that contains.a collection of creative writing, prose, poems, scripts - and the scripts are laid out using the conventions for screenplays, stage plays etc - using Scrivenerâs script writing elements. The whole project is really a âcollected worksâ omnibus. To print it as a physical book, I need to send PDF of the project to a print on demand service like Lulu. However, I want to print in both A4 and A5 physical sizes. The `Scrivener scriptwriting elements get compiled into Word styles that donât fit well on an A5 page (as they have fixed indents, set from the left hand margin that are setup for A4 pages). The fix, was to write a bit of visual basic, and then compile in Scrivener into Word .docx and then run the VB on that Word doc, to modify the Word styles that Scrivener had generated for the scriptwriting elements so that the modified Word styles then had the appropriate indents and margins. Then Word can generate an A5 sized PDF that looks pretty good. All of which works okay.
So I then thought, how do I document/preserve this VB code i have just written. It seems appropriate to put it into the same Scrivener project. And thatâs fine, it can be imported and exported as a .bas file in the âResearchâ area of the project. I can then put a note in the âResearchâ area of the project which reminds me how to use this VB code in the compile-to-pdf process.
But I mildly disappointed I could not see the contents of the VB file in Scrivener.
I can of course, rename the VB file and give it a .txt extension, then import it into Scrivern and the contents is visible (and indeed editable, though thatâs not really needed or even a good idea).
But then when I export it I have to remember to make it a .bas file again. Itâs just an extra step.
Given that when the .bas file is stored in Scrivener it is a simple readable format (ie there is no complicated metadata or non printing stuff in a VB .bas file, I wasnât sure why Scrivener did not want to show the contents of what in way could be seen to be a file in plain text RTF like format, just with a .bas extension.
Hereâs Scrivener looking at the SetScript
Fonts file with either a .bas or a .txt extension - but the same contents.
On macOS, you can go into the Sharing: Import settings tab, and in the Plain-Text section you will find a control to add custom extensions that Scrivener should recognise as plain-text, rather than importing as âunrecognisedâ or Quick Look preview-only. The downside is that it will import as regular text instead of the original file, so export will be oblivious as to its original file extension.
Otherwise, for something that is read-only, the best route is to find a Quick Look plug-in that will display it, that way you at least get something better than an empty icon.
