Question Sending a Publisher document as e-mail through Access (1 Viewer)

bifteki

Registered User.
Local time
Today, 23:31
Joined
Oct 24, 2008
Messages
23
Is there any way to run an MS Publisher macro through VBA?
Or sending a Publisher document as an e-mail through VBA, for that matter?

To be more explenative, I want to send a .pub document through an application
I'm making in Access.
Currently, I'm looking into the possibility of actually sending it through
Publisher via code, but with the user using the Access interface.
I've just done the declaration and initialization of the variables so far:

Private Sub btn_run_pub_macro_Click()

Dim pubDoc As Publisher.Document
Dim pubApp As New Publisher.Application

Set pubDoc = pubApp.Open("W:\MARKETING\FY10\FY10_WORKSHOPS\06.05 INVENTOR\
workshop invitation_0605.pub")

End Sub

I can't seem to find any method of the Publisher.Document or of the Publisher.
Application object that has to do with either sending the email or running a
macro.

Does anyone know how to do this?
 

bifteki

Registered User.
Local time
Today, 23:31
Joined
Oct 24, 2008
Messages
23
I don't think this will do, because I want to send a .pub file (as the body, not as an attachment).

The Publisher functionality I'm talking about is the Send e-mail --> Send as Message option from the File menu.

I want to run this action through Access. That is, the user will not be running Publisher but Access.
 

Atomic Shrimp

Humanoid lifeform
Local time
Today, 21:31
Joined
Jun 16, 2000
Messages
1,954
Does Publisher have any macro recording functionality? If so, you could record a macro and see how that does it - but even so, when you send a document via the menu in Publisher, is it actually publisher handling the email messaging? (it still shows up in your Outlook sent items folder?)


When you type (in your VBA code) pubDoc. and wait, do you get a code completion dropdown? - is there anything in there that looks hopeful?
 

bifteki

Registered User.
Local time
Today, 23:31
Joined
Oct 24, 2008
Messages
23
There is indeed a dropdown list when I type pubDoc but I haven't found anything useful (the only method that is close enough is MailMerge). Neither did I find anything in pubApp.

I tried recording a macro in Publisher as you said but in the dropdown list for ActiveDocument I didn't find any send command either. :confused:
When I send an email directly from Publisher, I can indeed find it in my Sent folder in Outlook. Does this mean that I can not reproduce this action through code?
 

Atomic Shrimp

Humanoid lifeform
Local time
Today, 21:31
Joined
Jun 16, 2000
Messages
1,954
I just looked at the macro functionality in Publisher - I thought it might have been like Excel, where you set a macro recording, do the stuff yourself, then go back and look at the code it has generated, but it doesn't seem to do that.

It may be that the mail sending functions in Publisher aren't exposed in the object model - I couldn't see any of them here.
 

GaryPanic

Smoke me a Kipper,Skipper
Local time
Today, 13:31
Joined
Nov 8, 2005
Messages
3,296
i don't think you can do this ...
you can attach a file (irrespective of the format )
but you cannot open it up in the body of the email - you need to get busy with html stuff

if you can save the pub as a web page you might be able to do something with it - otherwise your stuffed (I think)- mind you better brains then me will soon correct me.- but i have looked at this and could not see an easy way round it
 

bifteki

Registered User.
Local time
Today, 23:31
Joined
Oct 24, 2008
Messages
23
I have already examined various ways of sending this (damned) e-mail. I even saved it as an html and made a clr procedure to send it but there was a problem with the images.
Anyway, I'll see what else I can do.
Thank you both for your help. :)
 

Atomic Shrimp

Humanoid lifeform
Local time
Today, 21:31
Joined
Jun 16, 2000
Messages
1,954
Just out of interest - if you send a publisher document as an email in the way you've mentioned, what does it look like at the other end if the recipient does not have Publisher installed?
 

bifteki

Registered User.
Local time
Today, 23:31
Joined
Oct 24, 2008
Messages
23
If you send it through Publisher, it will be sent as the body of the email. Thus, it is converted into html and sent as such. So the recipient doesn't have to have Publisher. If you send the .pub document however as an attachment, of course the recipient needs to have Publisher installed.
 

Atomic Shrimp

Humanoid lifeform
Local time
Today, 21:31
Joined
Jun 16, 2000
Messages
1,954
Is it possible to get Access to automate Publisher to save the document as .mht (web page single file)?

If so, it might be possible to:

-- Save as single file web page (.mht)

-- Open the file as if it were a plain text file (i.e. Open "blah.mht" For Input As #1 or some such) and read the entire contents into a string variable

-- Using Outlook automation, create a message and insert the string as the HTMLBody element (using a function like this one - but where it says '.Body =' use '.HTMLBody =' instead)
 

Users who are viewing this thread

Top Bottom