[RESOLVED] Word Template Not Found
I'm writing my first ever VSTO application, and running into a bit of an oddity. I am trying to create a document based on a template like so:
Code:
Dim newDoc = Globals.ThisAddIn.Application.Documents.Add(Template:="C:\Users\etc\SCPTemplate1.dotx")
I altered the path slightly, to hide some information, but that shouldn't matter. This throws a file not found exception, and the details state that the file in question couldn't be found.
I checked the path, and that is correct, so I then added a check using IO.File.Exists() to see whether or not the file was there. This returned True, so the file is there, and the path is completely correct.
Furthermore, while the exception pops up, the program continues past that point. A file does exist, and it even pretty much looks like the template (I'm not quite certain of that, as I may have been looking at the wrong thing, and a second issue occurs right after that which is unrelated to this problem).
So, what is this exception about? Why am I getting it when I can verify that the path is correct and the file visible? And also, why does the fact of the exception not seem to have any impact on the behavior of the addin?
Re: Word Template Not Found
Re: Word Template Not Found
Darn, that answer makes it worse, if anything. The first didn't have any issue, the second is closer to what I was doing, and they report essentially the same error....but there isn't really a solution, unless the error they were getting came from setting the style, not from the template, and that issue doesn't apply to my situation. They suggest that changing away from .Style solved the problem, which would mean that the line where they created the document was NOT causing a problem, but it sure is for me.
Re: Word Template Not Found
Quote:
I altered the path slightly,
the path shown in the above should not cause an issue, but some other paths may do so if affected by virtualization
Re: Word Template Not Found
The alteration on the path was only changing the name of the folder, so it's a faithful representation of the what the actual folder is. Still, I think I'll try moving the template somewhere more...accessible.
Re: Word Template Not Found
The message that I'm getting is that it wasn't able to find this template:
file:///C:/Users/etc/Documents/SCPStuff/SCPTemplate1.vsto
I thought that this might have to do with trusted locations, so I added that folder to the trusted locations. That had no real impact. The code I am using comes directly from an MS document:
https://docs.microsoft.com/en-us/vis...s?view=vs-2019
And, aside from the fact that I get an error message each time...it is actually working. I had some other issues to work through when I originally posted this, but those have been worked through.
A further observation is that this doesn't appear to be a typical error message, though I don't have enough experience with automating Word to know. The error message has a title of "Microsoft Office Customization Manager", and it follows with Installing Customization (in bold), then on the next line, "There was an error during installation."
This set of facts suggests to me that I'm not really running into an error in my VSTO plugin, but an error in that Customization Manager, which I don't even know what that is. So, I'm off to see what I can find on that one.
Re: Word Template Not Found
And then I noticed the file extension....
So, it wasn't the template it couldn't find, which would be .dotx, it wasn't able to find the .vsto file, because that file wasn't there.
Frankly, I was going back and forth as to whether or not I should even use a template for this, and it is rather looking like the template is more trouble than it's worth. It doesn't gain me a whole lot, though I thought it might be ever so slightly easier to work with. However, while looking around at this error message, it began to look like I'll just keep running into issues if I try the template approach that I was using (which wasn't just a normal template, but a VSTO template).
So, I think this one can be said to be solved.