Consulting

Results 1 to 12 of 12

Thread: Solved: Registry Hack Wreaking Havoc

  1. #1

    Solved: Registry Hack Wreaking Havoc

    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...B;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

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Hi,



    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 [VBA] .Destination = wdSendToNewDocument[/VBA] 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!
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  3. #3
    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.

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    ps all the code is posted in the original thread referenced above.
    Hi,

    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:[VBA]
    Set wdDoc = wdApp.Documents.Open(WordDocFilePath)
    wdFileName = FinalReportFolder & "\ServiceCallLog_" & i & ".doc"
    wdDoc.SaveAs wdFileName
    wdDoc.Close[/VBA]
    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:
    [VBA] 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[/VBA]
    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!
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  5. #5
    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

  6. #6
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Hi Ross,

    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.
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  7. #7
    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

  8. #8
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Quote Originally Posted by rsilberfarb
    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,

    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!
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  9. #9
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    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.
    Last edited by mdmackillop; 04-18-2005 at 01:31 PM. Reason: General Revision
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  10. #10
    Administrator
    VP-Knowledge Base VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Hi,

    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:[VBA]
    With wdApp.ActiveDocument
    wdDoc.MailMerge.MainDocumentType = wdNotAMergeDocument 'this cuts off the data source
    wdDoc.Protect wdAllowOnlyFormFields
    wdDoc.SaveAs wdFileName
    wdDoc.Close
    End With
    [/VBA]
    Enjoy!
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

  11. #11
    THAT DID IT!!!!!


    THANKS A MILLION

    Ross

  12. #12
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Quote Originally Posted by rsilberfarb
    THAT DID IT!!!!!


    THANKS A MILLION

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

    Till the next encounter...
    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •