Msg to Albert D. Kallal - Help

B

Byron

Hi, Albert,

First, thanks for all of your hard work and the WordMerge
routine. It is great.

I do have one issue that I have not been able to
incorporate into your routine. I want to save the merged
document to a specific path and filename when the merge
is completed. I have tried the following code, with no
success. Here is the code from near the end of
your "RidesMergeWord" function:

WordDoc.Close (False)

wordApp.Visible = True
wordApp.Windows(wordApp.Windows.Count).Activate

MyPbar.HideProgress

' AppActivate "Microsoft Word"
wordApp.Activate

wordApp.WindowState = 0 'wdWindowStateRestore

wordApp.SaveAs strSaveDocTo & strNameOfDoc & ".doc"


Set wordApp = Nothing
Set WordDoc = Nothing
Set MyPbar = Nothing

Please note the:
wordApp.SaveAs strSaveDocTo & strNameOfDoc & ".doc"

statement. This is the statement that I am attempting to
use to save the merged document. I still want the merged
document to be the active document, after it is saved to
the new path and filename.

Thanks for any help,

Byron
 
A

Albert D. Kallal

Hi, Albert,

First, thanks for all of your hard work and the WordMerge
routine. It is great.

Thank you very much. On the other hand, it is SORELY in need of a web page
on how to use it!!!
I do have one issue that I have not been able to
incorporate into your routine. I want to save the merged
document to a specific path and filename when the merge
is completed.

It turns out that "most" of the code has the ability for you to specify the
output document. I can't remember when I put that code in, but it was some
time ago. However, the two commands did NOT have support for specify the
output doc...they now do.

So, I just changed the code to allow you to set/specify the output doc.

So, to execute a merge on the current record, and send the document, you can
use:

MergeSingleWord ,,"c:\myDocs\test.doc"

Or, to merge a bunch, you can use:

MergeAllWord ("select * from Contacts"),,,"c:\myDocs\test.doc"

Since the code was modified, then to update your existing code, you would do
the following to your existent application:

delete the module wordcode
delete the form GuiWordTemplate

Now, import the above two objects from the "new" version. You can find that
new version here:

(a2000 and later has these updates).
 
B

Byron

-----Original Message-----


Thank you very much. On the other hand, it is SORELY in need of a web page
on how to use it!!!


It turns out that "most" of the code has the ability for you to specify the
output document. I can't remember when I put that code in, but it was some
time ago. However, the two commands did NOT have support for specify the
output doc...they now do.

So, I just changed the code to allow you to set/specify the output doc.

So, to execute a merge on the current record, and send the document, you can
use:

MergeSingleWord ,,"c:\myDocs\test.doc"

Or, to merge a bunch, you can use:

MergeAllWord ("select * from Contacts"),,,"c:\myDocs\test.doc"

Since the code was modified, then to update your existing code, you would do
the following to your existent application:

delete the module wordcode
delete the form GuiWordTemplate

Now, import the above two objects from the "new" version. You can find that
new version here:

(a2000 and later has these updates).


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(e-mail address removed)
http://www.attcanada.net/~kallal.msn


.
Albert,

Thanks for the info. I will get the lates updates and
give them a try. I have found what you have here to be
of great value when attempting to do a merge to Word.

I do have one more question or just an observation:

What I discovered is that what I thought I was doing was
not at all what I really needed to accomplish. I am
working on an application where legal documents are being
prepared, printed and saved. I will not be able to use
the merge method to build documents as I had planed,
because when they are reopened (at a later time) if users
have changed any of the data in the database then the
information in the merged document will be different from
the one that was actually printed.

Do you have any thoughts along this line. Right now I am
going back to the "Bookmark" method for creating the
finished document due to the fact that I need a
completed, actual hard copy to save for future reference.

Any thoughts you or anyone else may have along these
lines will be appreciated.

Byron
 
A

Albert D. Kallal

Albert,

Thanks for the info. I will get the lates updates and
give them a try. I have found what you have here to be
of great value when attempting to do a merge to Word.

I do have one more question or just an observation:

What I discovered is that what I thought I was doing was
not at all what I really needed to accomplish. I am
working on an application where legal documents are being
prepared, printed and saved. I will not be able to use
the merge method to build documents as I had planed,
because when they are reopened (at a later time) if users
have changed any of the data in the database then the
information in the merged document will be different from
the one that was actually printed.

No, not with my example code. If you change data, and then make a NEW
document, then of cause that new document will reflect the changes. However,
my code DOES NOT save the merged fields. In fact, I have the same results as
if you had used bookmarks. When my code runs, all fields and merge stuff is
removed. The result is a fixed plain Jane document.
Do you have any thoughts along this line. Right now I am
going back to the "Bookmark" method for creating the
finished document due to the fact that I need a
completed, actual hard copy to save for future reference.

Any thoughts you or anyone else may have along these
lines will be appreciated.

I am totally missing something here??? Fact is, my merge code creates a
plain Jane document WITH NO MERGE fields. If you re-merge the document and
OVERWRITE the old one..then of course it will change..but so would be the
case if you used book marks. So, your problem here is not using merged
fields (because my resulting merged documents have NO merge fields in it. If
you change the data in the database, those document you already made will
NOT be updated. So, sure, the problem will exist if you re-run the merge
again,a and OVERWRITE the existing document, then course the old document is
lost. However, the exact same thing would occur with bookmarks.

How would using book marks solve this problem??? What would be different?
 
B

Byron

-----Original Message-----


No, not with my example code. If you change data, and then make a NEW
document, then of cause that new document will reflect the changes. However,
my code DOES NOT save the merged fields. In fact, I have the same results as
if you had used bookmarks. When my code runs, all fields and merge stuff is
removed. The result is a fixed plain Jane document.


I am totally missing something here??? Fact is, my merge code creates a
plain Jane document WITH NO MERGE fields. If you re- merge the document and
OVERWRITE the old one..then of course it will change..but so would be the
case if you used book marks. So, your problem here is not using merged
fields (because my resulting merged documents have NO merge fields in it. If
you change the data in the database, those document you already made will
NOT be updated. So, sure, the problem will exist if you re-run the merge
again,a and OVERWRITE the existing document, then course the old document is
lost. However, the exact same thing would occur with bookmarks.

How would using book marks solve this problem??? What would be different?


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(e-mail address removed)
http://www.attcanada.net/~kallal.msn


.
Albert,

Thanks again for your help.

Well, I will just have to re-visit my situation. I feel
sure that I am the one who has missed something here.

I had to do some modification to the end of your code.
What I needed it to do was to save the completed document
to a specified path and name and then present the
completed document to the user.

Here is the modified code from your
*****Start Code*****
MyPbar.IncOne ' step 4, doc is merged

WordDoc.Close (False)

wordApp.Visible = True
wordApp.Windows(wordApp.Windows.Count).Activate

MyPbar.HideProgress

' AppActivate "Microsoft Word"
wordApp.Activate

wordApp.WindowState = 0 'wdWindowStateRestore

wordApp.SaveAs strSaveDocTo & strNameOfDoc & ".doc"


Set wordApp = Nothing
Set WordDoc = Nothing
Set MyPbar = Nothing

DoEvents
*****End of Code****

The only statement that is suspect is:
wordApp.SaveAs strSaveDocTo & strNameOfDoc & ".doc"

Am I doing something here that I should not do with your
code?

If so, what is the best way to accomplish saving the
document to the specific location and name.

I may have had some other issue going on, but I was not
aware of any. I will re-visit my effort and see if I can
resolve. If your code will produce a completd document
without merge codes, then by all means, I was to use your
method. It certainly make it much simpler to code and to
let the user create new, usable, documents.

Thanks, again.

Byron
 
B

Byron

-----Original Message-----


No, not with my example code. If you change data, and then make a NEW
document, then of cause that new document will reflect the changes. However,
my code DOES NOT save the merged fields. In fact, I have the same results as
if you had used bookmarks. When my code runs, all fields and merge stuff is
removed. The result is a fixed plain Jane document.


I am totally missing something here??? Fact is, my merge code creates a
plain Jane document WITH NO MERGE fields. If you re- merge the document and
OVERWRITE the old one..then of course it will change..but so would be the
case if you used book marks. So, your problem here is not using merged
fields (because my resulting merged documents have NO merge fields in it. If
you change the data in the database, those document you already made will
NOT be updated. So, sure, the problem will exist if you re-run the merge
again,a and OVERWRITE the existing document, then course the old document is
lost. However, the exact same thing would occur with bookmarks.

How would using book marks solve this problem??? What would be different?


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(e-mail address removed)
http://www.attcanada.net/~kallal.msn


.

Albert,

I took another look and figured out that the suspect code
that I mentioned in my previous email, was not actually
working to save the active document. When I fixed this,
I was able to complete what I wanted. Sorry for all the
flap, but sometimes I have to go through a lot to get
there.

I would like to ask you one, quick, unrelated question:
Is it possible to display a popup menu by clicking a
command button. I have not been able to do it.

Thanks,

Byron
 
A

Albert D. Kallal

Byron said:
Albert,

I took another look and figured out that the suspect code
that I mentioned in my previous email, was not actually
working to save the active document. When I fixed this,
I was able to complete what I wanted. Sorry for all the
flap, but sometimes I have to go through a lot to get
there.

As notened you don't need to modify the code at all to get it to save a
doument of your choice. This feature is build in.

(there is no need to modify the code).

If you want to use a template, and have the document saved,but still
dispalyed to the user, you can use:

dim strTemplate as string
dim strDocToSave as string

strTemplate = "OverDueBill.doc"
strDirWhereTemplateIs = "c:\My Cool Templates\"

strDocToSave = "c:\OverDueBills\AlbertKallal.doc"

MergeNoPrompts strTemplate, strDirWhereTemplateIs, True, strDocToSave

The above would execute the word merge,create the neew document we seiclled,
and the user would now looking at the displayed document. No prmpts would
occur.

Of couse, you might actually want the user to select a tamplte, and still
specify the output document, you can also do that, example:

MergeSingleWord "c:\testfrom\", True, "c:\testto\Today.doc"


So, the first example executes a merge, no prmpts, and creates the document
of your choice. Then 2nd example would let the user select the document
(template), but your code STILL sets the final output document name.

So, really, no need to try and modify the code, as the above two commands
(MergeSingleWord, and MergeNoPrompts) can be used to create your docuemnts.
I would like to ask you one, quick, unrelated question:
Is it possible to display a popup menu by clicking a
command button. I have not been able to do it.

Hum, I kind of thought:

commandbars("your bar").Visible = true.

Would work. However, I don't think the above works for pop ups (so, no, I
don't have an answer). I think it just has to be a menu/toolbar, and not a
popup. I suppose you could just specify the right click menu for a control,
a button, and even the whole form? (but, you would be talking about right
click..and not a normal click).
 
B

Byron

-----Original Message-----


As notened you don't need to modify the code at all to get it to save a
doument of your choice. This feature is build in.

(there is no need to modify the code).

If you want to use a template, and have the document saved,but still
dispalyed to the user, you can use:

dim strTemplate as string
dim strDocToSave as string

strTemplate = "OverDueBill.doc"
strDirWhereTemplateIs = "c:\My Cool Templates\"

strDocToSave = "c:\OverDueBills\AlbertKallal.doc"

MergeNoPrompts strTemplate, strDirWhereTemplateIs, True, strDocToSave

The above would execute the word merge,create the neew document we seiclled,
and the user would now looking at the displayed document. No prmpts would
occur.

Of couse, you might actually want the user to select a tamplte, and still
specify the output document, you can also do that, example:

MergeSingleWord "c:\testfrom\", True, "c:\testto\Today.doc"


So, the first example executes a merge, no prmpts, and creates the document
of your choice. Then 2nd example would let the user select the document
(template), but your code STILL sets the final output document name.

So, really, no need to try and modify the code, as the above two commands
(MergeSingleWord, and MergeNoPrompts) can be used to create your docuemnts.


Hum, I kind of thought:

commandbars("your bar").Visible = true.

Would work. However, I don't think the above works for pop ups (so, no, I
don't have an answer). I think it just has to be a menu/toolbar, and not a
popup. I suppose you could just specify the right click menu for a control,
a button, and even the whole form? (but, you would be talking about right
click..and not a normal click).


--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(e-mail address removed)
http://www.attcanada.net/~kallal.msn


.
Thank you so very much for taking your time to assist me.

I really appreciate it. I will try all of the options you
have proposed and I'm sure all will work for me.

This routine of yours surly beats anything else that I
have seen or tried. It is so simple and easy to use, but
so powerful. I did not realize some of the things you
have described in you last posting.

Thanks again.

Byron
 

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