PbSaveOptions.pbSaveChanges causes exception

G

Glenn W.

I'm trying to automate the daily updating of my company's price list, which
is a publisher file, programmatically. Lots of details I will probably have
to ask about later, but the problem I'm having now is that I can't open my
publisher file using the Application Open() function with the
PbSaveOptions.pbSaveChanges option set. My code looks like this:

Application pubApp = new Application();
Document availabilityDoc = pubApp.Open(availListFile, false,
false, PbSaveOptions.pbSaveChanges);

where 'availListFile' is a string holding the path and filename of the file
I want to open. It's on the local c: drive.

It compiles fine but at runtime I get the exception "Value does not fall
within the expected range." If I change pbSave Changes to either of the
other two options, 'pbPromptToSaveChanges' or 'pbDoNotSaveChanges', I don't
get that exception. However, I really do want my changes saved when I close
the document, and because I want it to execute automatically in the middle
of the night, I don't want to have to answer a prompt. I'm using Visual
Studio 2005 and I've referenced MS Publisher 12.0 Object library. If it
matters, I've got MS Publisher 2007 loaded on my machine.

I don't think it's a permissions issue as I've opened everything up, both
the file and the folder it's in, so there shouldn't be an access issue.

Any ideas how I can get around this and still keep the changes I'll be
making to my file? Thanks!

Glenn
 
E

Ed Bennett

It compiles fine but at runtime I get the exception "Value does not fall
within the expected range." If I change pbSave Changes to either of the
other two options, 'pbPromptToSaveChanges' or 'pbDoNotSaveChanges', I
don't get that exception. However, I really do want my changes saved
when I close the document, and because I want it to execute
automatically in the middle of the night, ....
Any ideas how I can get around this and still keep the changes I'll be
making to my file? Thanks!

Execute a Document.Save() immediately before you close the document and
you should not be prompted. (I have no idea why PbSaveChanges isn't
working; when I get a moment I'll take a look. I remember having similar
random issues when I tried to program against Publisher in C#, but
thought it was just my poor C# skills. I've had no similar problems in
VB.NET.)

Note that unattended Office server applications are currently
unsupported, per http://support.microsoft.com/kb/257757

Look out for the microsoft.public.publisher.programming newsgroup, for
all your programmability-related questions.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top