jasoncw
10-24-2007, 02:08 PM
I tried posting this on another forum, but did not get a solution yet. Here is the link in case you are interested:
http://www.excelforum.com/showthread.php?t=619234
This is an Excel file, and the reason I am posting here is because the code that is not working is actually Word VBA within the Excel VBA module. I will try to explain a little better for you below.
Using Office 97/Win 2k Pro and Office 2003/Win XP Pro, I am having the same results.
I have an Excel workbook that creates a Word document using a command button and userform. The command button calls the user form, data is entered by the user, and when a command button on the user form is clicked, the document is generated.
Sometimes, I can step through the procedure, and it will work all the way through. Sometimes, it seems as if I step through too fast, the procedure seems to just stop without warning, and will not go any further. If I try to run the procedure by simply clicking the command button, it will usually not run all the way through. The stopping points appear to be somewhat random, but all after the Word App is created and after both Word files are opened.
I am attaching files to make it easier for anyone who is trying to help me replicate the problem. On the 2008 Log.xls file (password is "password" if you need to unprotect it), I changed the name of the files in the code to refer to:
C:\Temp\DM.doc
and
C:\Temp\LH.dot
DM.doc is the letter that is opened and modified. LH.dot is our company's letterhead that is opened, header copied, and closed. Please save both of these to C:\Temp to properly work.
The code to open and edit the Word document is in Module2 of 2008 Log.xls. I did make several changes to the Excel and Word files, since some of the information was proprietary, but it should still work as intended.
If it works for you the first time, please close Word and try it again. Every once in a while it will work for me just fine. But if I try it again, it will not work properly. I moved the visibility and activation of the Word app to the beginning of the procedure, in order to help see the stopping point of the code.
I really appreciate any help on this issue.
Jason
http://www.excelforum.com/showthread.php?t=619234
This is an Excel file, and the reason I am posting here is because the code that is not working is actually Word VBA within the Excel VBA module. I will try to explain a little better for you below.
Using Office 97/Win 2k Pro and Office 2003/Win XP Pro, I am having the same results.
I have an Excel workbook that creates a Word document using a command button and userform. The command button calls the user form, data is entered by the user, and when a command button on the user form is clicked, the document is generated.
Sometimes, I can step through the procedure, and it will work all the way through. Sometimes, it seems as if I step through too fast, the procedure seems to just stop without warning, and will not go any further. If I try to run the procedure by simply clicking the command button, it will usually not run all the way through. The stopping points appear to be somewhat random, but all after the Word App is created and after both Word files are opened.
I am attaching files to make it easier for anyone who is trying to help me replicate the problem. On the 2008 Log.xls file (password is "password" if you need to unprotect it), I changed the name of the files in the code to refer to:
C:\Temp\DM.doc
and
C:\Temp\LH.dot
DM.doc is the letter that is opened and modified. LH.dot is our company's letterhead that is opened, header copied, and closed. Please save both of these to C:\Temp to properly work.
The code to open and edit the Word document is in Module2 of 2008 Log.xls. I did make several changes to the Excel and Word files, since some of the information was proprietary, but it should still work as intended.
If it works for you the first time, please close Word and try it again. Every once in a while it will work for me just fine. But if I try it again, it will not work properly. I moved the visibility and activation of the Word app to the beginning of the procedure, in order to help see the stopping point of the code.
I really appreciate any help on this issue.
Jason