PDA

View Full Version : Insert file



JayM
03-30-2010, 02:54 AM
I currently have a macro(written for MS Word) which inserts a selected file
from a directory.

Sub GeneralUsertextClauses()
With Dialogs(wdDialogInsertFile)
.name = varUSERTEXT
.Show
End With
End Sub

varusertext is referenced as follows:
Global Const varUSERTEXT As String = "w:\zzword97\usertext\"

How can I ensure that the selected file isn't an attachment when used with
Outlook but is just inserted into the body of the text (word is my editor)?

fumei
03-30-2010, 08:32 AM
You have cross posted this, and have received an answer there. Perhaps not a full answer, but an answer nonetheless.

I am deliberately not stating where "there" is.

JayM
03-30-2010, 09:24 AM
Sorry has this offended you that I have cross posted. I was hoping to get a more useful answer than I got "there".

still hopeful that someone might have a workaround for this:hi:

lucas
03-30-2010, 09:42 AM
read this and respond and we will go from there (http://www.excelguru.ca/node/7).

fumei
03-30-2010, 10:00 AM
Well I am afraid you are going to have to accept the answer...and the questions that were posed.

You did not offend me at all.

Is this an Outlook question? Shrug, not really.

You question is: "How can I ensure that the selected file isn't an attachment when used with Outlook"

Simply put...you can't. You are giving a path and filename, so BY DEFINITION it is not an attachment. At least in this context.

Oh sure, it may ALSO be an attachment to some email, but that is totally, completely, irrelevant. Why?

Because your code has NOTHING to do with Outlook.

And until you clearly explain: "when used with Outlook"....

used HOW???

there is no other better answer.

It has nothing to do with Outlook.

Global Const varUSERTEXT As String = "w:\zzword97\usertext\"

is a (one would assume) valid path/filename to a file at that location on your drive...and has nothing to do with Outlook.

fumei
03-30-2010, 12:27 PM
Here is what you posted over there...

"The relevance of Outlook is that these files could be inserted into word
documents (for letters) or into emails if you are sending a email to a Client.

The files could be standard paragraphs or addresses etc "

What, pray tell, has this to do with attachments? They seems to be text content that may be inserted into either a Word document, OR an Outlook email. In which case, are you using an Outlook instance, or are you using Word to send an email.

We can probably help you, but I for one do not know what you actually asking about. You did not bother to respond over there, so I have to wonder what you are doing. You posted 9as well) to th eOutlook forum and gone ANOTHER reply - to which you did not bother to respond to either - which stated (as I have):

"You can't. You'd need to be using the Outlook object model and adding an
attachment using Outlook code."

So why don't you start again and tell us what you really want to do.

JayM
03-31-2010, 02:15 AM
Firstly I would like to apologise as I do appear to have offended you and I am sincerely sorry for that.

I have learnt from this and will in future let everyone know if have posted elsewhere.

Secondly I originally posted my query on a Word VBA board as my original code was written for word documents but they informed me that this was an Outlook issue and therefore I posted on an Outlook board.

The deal is this. I will try to explain as best as I can but sometimes I have difficulty putting into words what it is I require.

the original code was written by someone who no longers works with me and i believe he wrote more VB than VBA. I understand that there are differences but don't totally understand them.

we have some 120 users who use standard paragraphs all the time even across different departments so code was written to insert paragraphs into word documents. some people have taken this to extremes and put whole letters into these documents.

The original code used an input message box so the user could type the name of the document they required to insert but I wanted to change this so that they could do either, type the name of the document or look it up. So I created a userform in word and a macro shows the form and the user can then either type in the name of the document and press enter and the file is inserted into their current document or they can click on a button which takes them to the folder so they can browse to the file they require. When they select that document in word it inserts the text into the document but in Outlook (using word as the editor) it simply attaches the document to the email.

I will try and attach doc with screen shots and code.

JayM

fumei
03-31-2010, 09:47 AM
That is much better. OK...

" in Outlook (using word as the editor) "

This is the point that has been tried. in Outlook Please clarify what - exactly - does this mean. You are "in" Outlook, and you are trying to use this?

BTW: I would strongly recommend you use Option Explicit. It will save you a lot of problems in the long run.