Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Publisher / Programming / May 2007

Tip: Looking for answers? Try searching our database.

Closing modal form & application

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
J Holtendehouzer - 18 May 2007 00:03 GMT
I'm used to Visual Studio 2005, and I've been trying to create a solution in
Publisher using VBA.  The differences are frustrating me...

I want to generate instructions for medical patients.  The user (a nurse)
needs to be able to type in a name, select an age group and a sex, then check
off several types of instructions (e.g., diabetes, hypertension, etc.).

My solution should then open each publisher document (I used publisher
because the flyer formatting was easier than in word), insert the patient's
name in the right places, and print each one out.  Then, I want the documents
to close, and I'd actually like the whole application to close also.

I have everything working--EXCEPT closing the documents I opened, and the
modal user form I'm using as a UI, so I can close the original publisher app.
Any ideas?  Am I making sense?

Thanks!
Joe
Ed Bennett - 19 May 2007 01:03 GMT
> I'm used to Visual Studio 2005, and I've been trying to create a solution in
> Publisher using VBA.  The differences are frustrating me...

Why not write your solution in VS05?

> I have everything working--EXCEPT closing the documents I opened, and the
> modal user form I'm using as a UI, so I can close the original publisher app.
>  Any ideas?  Am I making sense?

I don't think you're allowed to close the instance of Publisher from
which the form was called, but I think any other instances you've
instantiated can be closed. Writing an application that automates
Publisher from the outside rather than a VBA script inside Publisher
will allow this.

Signature

Ed Bennett - MVP Microsoft Publisher
http://ed.mvps.org

J Holtendehouzer - 19 May 2007 02:57 GMT
Thanks for your reply, Ed.  I had the understanding that VS05 with VSTO
doesn't support automating Publisher.  Is that incorrect?

I would LOVE to write it in VS05--it's a much more familiar environment for
me.  However, I haven't been able to make it work.

Can you point me to a remedial explanation of how to do what I need to do?  
(I'm kind of an idiot!)

Thanks in advance,
Joe

> > I'm used to Visual Studio 2005, and I've been trying to create a solution in
> > Publisher using VBA.  The differences are frustrating me...
[quoted text clipped - 10 lines]
> Publisher from the outside rather than a VBA script inside Publisher
> will allow this.
Ed Bennett - 19 May 2007 11:30 GMT
> Thanks for your reply, Ed.  I had the understanding that VS05 with VSTO
> doesn't support automating Publisher.  Is that incorrect?

VSTO doesn't support Publisher, but that doesn't stop you from simply
automating Publisher through its COM interface (the same way VBA works,
I think, and the same as writing an add-in).

I'm not aware of any guides for automating Publisher, but it's pretty
simple. Add references to the Publisher Object Library and the Office
Object Library (you MUST have the PIAs for Office installed before doing
this - check your GAC or run through a custom Office Setup and make sure
they're checked - look for '.Net Programmability Support'), and then
create a new instance of Publisher with:

VB:
Dim pbApp As New Microsoft.Office.Interop.Publisher.Application

C# (probably):
Microsoft.Office.Interop.Publisher.Application pbApp = new
Microsoft.Office.Interop.Publisher.Application();

Then declare a Publisher.Document and use the pbApp.Open method to give
it a document. Etc.

Signature

Ed Bennett - MVP Microsoft Publisher
http://ed.mvps.org

J Holtendehouzer - 19 May 2007 15:14 GMT
Ed, you're awesome.  Thanks!

> > Thanks for your reply, Ed.  I had the understanding that VS05 with VSTO
> > doesn't support automating Publisher.  Is that incorrect?
[quoted text clipped - 19 lines]
> Then declare a Publisher.Document and use the pbApp.Open method to give
> it a document. Etc.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.