PDA

View Full Version : Solved: Registry Hack Wreaking Havoc



rsilberfarb
04-05-2005, 02:37 PM
I have gotten some great help from Killian on this board, but he suggested I pose this issue here.

In order to run some VBA code to automate a form being generated, I employed this registry hack

http://support.microsoft.com/default.aspx?scid=KB;EN-US;825765

This enabled the VBA code to what it needed to, but now I do not have the ability to un-link the word doc from the mail merge. So after the process completes, I save the form with a unique name, when I open it again, it replaces the actual info, with what is currently ing the source file.

Long story short, I want to keep the regisrty settin gthe way it is, and still be able to un-link the doc.

Any ideas.

Original Post Here
http://www.vbaexpress.com/forum/showthread.php?t=2331

MOS MASTER
04-06-2005, 11:33 AM
Hi, :D



I don?t understand you?re question so bare with me.

The registry hack is just to disable the SQL warning box (New security feature > SP3 XP)

It should not interfere with the execution of you?re code..so you lost me there..

But from you?re story it seams like you?re doing a mail merge in which you?re trying to save each document as a new document? (Am I right?)

And the problem is that the new document stays bound to the datasource?

If so make shure that you?re procedure uses the .Destination = wdSendToNewDocument property and constant to make each document a new document without binding to the datasource..

If this is not what you?re looking for?provide the VBA code you?re running so I can see what you?re trying to achieve.

Enjoy! :thumb

rsilberfarb
04-07-2005, 12:55 PM
Thanks for the reply. Your assumptions are correct.

Assume I know nothing about VBA, where do I put the line of code.



ps all the code is posted in the original thread referenced above.

MOS MASTER
04-07-2005, 02:04 PM
ps all the code is posted in the original thread referenced above. Hi, :D

I think you're refering to :
http://www.vbaexpress.com/forum/showthread.php?t=2331
That topic is about Outlook and I see a lot of code in there but I don?t see any lines of code that have any relation with the Word ?Mailmerge Object model?!
What I do see is these lines:
Set wdDoc = wdApp.Documents.Open(WordDocFilePath)
wdFileName = FinalReportFolder & "\ServiceCallLog_" & i & ".doc"
wdDoc.SaveAs wdFileName
wdDoc.Close
Seams like the code wich comes first to the above lines is filling an excel sheet with only one row off values and saves the sheet.
The lines a copied out the topic:
Then the Word doc is opened and the data is bound (if binding was there) to the document. And yes when you save as a document that?s bound in this way you get another bound document..
From the top I?d suggest something like:
Set wdDoc = wdApp.Documents.Open(WordDocFilePath)
wdFileName = FinalReportFolder & "\ServiceCallLog_" & i & ".doc"
With wdDoc.MailMerge
.Destination = wdSendToNewDocument
.Execute
With wdApp.ActiveDocument
.SaveAs wdFileName
.Close
End With
End With
wdDoc.Close
Presuming the binding to the source is made I think this should work..If not then come back and I?ll rebuild you?re environment on my pc to test what does work..
Enjoy!

rsilberfarb
04-18-2005, 09:50 AM
Sorry for the late reply, I was pulled away on another project. Unfortunately, unless I am missing something this fox did not kill the link between the word doc and the data source.

Any other Ideas?

Thanks Again,

Ross

MOS MASTER
04-18-2005, 11:36 AM
Hi Ross, :D

No problem. The question was / is still not 100% clear to me.

Could you please make a test set off you're files and post them here? (The question seams scatterd over numerous thread's so that's to much to overview)

Then I will run a test on them and see what I can do to solve you're problem. :thumb

rsilberfarb
04-18-2005, 11:45 AM
To clarify (although I think you have it right), the script creates a word form populated by and excell data source. In order to get it to run properly, I employed the regisrty hack noted above. With this in place, when I open an old form, it is still linked to whatever data is currently in the excel source file.


I have attached the excel file, the word form template, and a text file of an e-mail that drives the process.

The excel is set to auto run the script and look for the text file e-mail saved in the location listed in the code. From there it opens the form template, populates it and save the completed form to a new file.

Let me know if this makes sense.

Thanks again,

Ross

MOS MASTER
04-18-2005, 11:55 AM
To clarify (although I think you have it right), the script creates a word form populated by and excell data source. In order to get it to run properly, I employed the regisrty hack noted above. With this in place, when I open an old form, it is still linked to whatever data is currently in the excel source file.


I have attached the excel file, the word form template, and a text file of an e-mail that drives the process.

The excel is set to auto run the script and look for the text file e-mail saved in the location listed in the code. From there it opens the form template, populates it and save the completed form to a new file.

Let me know if this makes sense.

Thanks again,

Ross
Hi Ross, :D

I've just been challenged to do something else tonight so I will take a look at it like I said tommorow.

Thank you for explaining..I'm sure we can make this work! :thumb

mdmackillop
04-18-2005, 12:11 PM
I've created the folders etc as per your example, and it is running for me as designed. (Office 2003, WinXP Pro)
I've zipped up your files and the folder structure which needs to be extracted into "c:\documents and settings" for others to try. I've copied and amended your text file slightly to give 3 output files which should appears in the Forms sub-folder after the code is run.

Opening the Excel file runs the code automatically.
I've turned off screen updating in excel to speed things up a little
I've turned off the "send email" bit of the code in Excel for testing purposes.

MOS MASTER
04-18-2005, 01:23 PM
Hi, :D

Okay had a quick look at it and seeing the total picture now!
You just need a simple alteration to the code to disconnect the datasource in the document.

I've cut this piece off the code so you can find the part to change easilly:
With wdApp.ActiveDocument
wdDoc.MailMerge.MainDocumentType = wdNotAMergeDocument 'this cuts off the data source
wdDoc.Protect wdAllowOnlyFormFields
wdDoc.SaveAs wdFileName
wdDoc.Close
End With

Enjoy! :thumb

rsilberfarb
04-18-2005, 01:35 PM
THAT DID IT!!!!!


THANKS A MILLION

Ross

MOS MASTER
04-18-2005, 01:38 PM
THAT DID IT!!!!!


THANKS A MILLION

RossHi Ross, :D
You're welcome...have one on me :beerchug:
(please don't forget to mark you're thread solved?)

Till the next encounter...