Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Help With Word Automation

Help With Word Automation

Scheduled Pinned Locked Moved Web Development
helptestingtools
8 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sokar
    wrote on last edited by
    #1

    I could really use some help with a problem I am having using Word Automation. Using ASP I have created an Online Reports Website were our Project Managers go and upload their status reports to the website itself. My boss wants me to combine the single reports into one big report as they are being uploaded to the site. The only way that I can figure out to do it is with Automation. I have never done it before or for that matter heard of it before. I have this so far. set objWord = CreateObject("Word.Application") set objAppendFileFSO = CreateObject("Scripting.FileSystemObject") if objAppendFileFSO.FileExists(strAppendFileName) then Set newReport = objWord.Documents.Add(strReadFile) set completeReport = objWord.Documents.Add(strAppendFileName) newReport.Selection.WholeStory() newReport.Selection.Copy() completeReport.Selection.PasteAndFormat(wdPasteDefault) completeReport.InsertPagebreak() completeReport.ActiveDocument.Close() newReport.ActiveDocument.Close() else Set newReport = objWord.Documents.Add(strReadFile) set completeReport = objWord.Documents.Add() newReport.ActiveWindow.Selection.Range.WholeStory newReport.ActiveWindow.Selection.Range.Copy completeReport.Add.Content.Paste 'completeReport.ActiveWindow.Selection.PasteAndFormat(report) completeReport.InsertPagebreak() completeReport.SaveAs("D:\Inetpub\wwwroot\CJISReport\CJISreportPage\" & strYear & "\monthlyList\" & strmonth & "\MajorProjects\All Reports.doc") completeReport.ActiveDocument.Close() newReport.ActiveDocument.Close() end if The if is to determine if it was the first report of the month. It will create the new report if so. There is different code in them cause I have been trying different things with each of them and unfortuenetly none of them work. It just tells me this error: Permission Denied. It tells me this for the line "end if". I have no Idea what this means. Any help would be really apprecieated. Thank you in advanced. Sokar ctl - alt - del if that dosen't work, bang your head on the keybord.

    S 2 Replies Last reply
    0
    • S Sokar

      I could really use some help with a problem I am having using Word Automation. Using ASP I have created an Online Reports Website were our Project Managers go and upload their status reports to the website itself. My boss wants me to combine the single reports into one big report as they are being uploaded to the site. The only way that I can figure out to do it is with Automation. I have never done it before or for that matter heard of it before. I have this so far. set objWord = CreateObject("Word.Application") set objAppendFileFSO = CreateObject("Scripting.FileSystemObject") if objAppendFileFSO.FileExists(strAppendFileName) then Set newReport = objWord.Documents.Add(strReadFile) set completeReport = objWord.Documents.Add(strAppendFileName) newReport.Selection.WholeStory() newReport.Selection.Copy() completeReport.Selection.PasteAndFormat(wdPasteDefault) completeReport.InsertPagebreak() completeReport.ActiveDocument.Close() newReport.ActiveDocument.Close() else Set newReport = objWord.Documents.Add(strReadFile) set completeReport = objWord.Documents.Add() newReport.ActiveWindow.Selection.Range.WholeStory newReport.ActiveWindow.Selection.Range.Copy completeReport.Add.Content.Paste 'completeReport.ActiveWindow.Selection.PasteAndFormat(report) completeReport.InsertPagebreak() completeReport.SaveAs("D:\Inetpub\wwwroot\CJISReport\CJISreportPage\" & strYear & "\monthlyList\" & strmonth & "\MajorProjects\All Reports.doc") completeReport.ActiveDocument.Close() newReport.ActiveDocument.Close() end if The if is to determine if it was the first report of the month. It will create the new report if so. There is different code in them cause I have been trying different things with each of them and unfortuenetly none of them work. It just tells me this error: Permission Denied. It tells me this for the line "end if". I have no Idea what this means. Any help would be really apprecieated. Thank you in advanced. Sokar ctl - alt - del if that dosen't work, bang your head on the keybord.

      S Offline
      S Offline
      Sage
      wrote on last edited by
      #2

      sounds to me like the files are marked readonly (doubtful) or that you dotn have write permission on that folder. Check that out first and then let me know if that was the reason. - Sage

      S 1 Reply Last reply
      0
      • S Sage

        sounds to me like the files are marked readonly (doubtful) or that you dotn have write permission on that folder. Check that out first and then let me know if that was the reason. - Sage

        S Offline
        S Offline
        Sokar
        wrote on last edited by
        #3

        I have full control over the folder(I am running locally on my computer). THe files are not read only files. I am pretty sure that It has something to do with the copy and past part. I have been playing around with the word macros in the VB editor and have had some ideas but nothing has born fruit as of yet. btw, thank you for helping I do appriciate it. Sokar ctl - alt - del if that dosen't work, bang your head on the keybord.

        1 Reply Last reply
        0
        • S Sokar

          I could really use some help with a problem I am having using Word Automation. Using ASP I have created an Online Reports Website were our Project Managers go and upload their status reports to the website itself. My boss wants me to combine the single reports into one big report as they are being uploaded to the site. The only way that I can figure out to do it is with Automation. I have never done it before or for that matter heard of it before. I have this so far. set objWord = CreateObject("Word.Application") set objAppendFileFSO = CreateObject("Scripting.FileSystemObject") if objAppendFileFSO.FileExists(strAppendFileName) then Set newReport = objWord.Documents.Add(strReadFile) set completeReport = objWord.Documents.Add(strAppendFileName) newReport.Selection.WholeStory() newReport.Selection.Copy() completeReport.Selection.PasteAndFormat(wdPasteDefault) completeReport.InsertPagebreak() completeReport.ActiveDocument.Close() newReport.ActiveDocument.Close() else Set newReport = objWord.Documents.Add(strReadFile) set completeReport = objWord.Documents.Add() newReport.ActiveWindow.Selection.Range.WholeStory newReport.ActiveWindow.Selection.Range.Copy completeReport.Add.Content.Paste 'completeReport.ActiveWindow.Selection.PasteAndFormat(report) completeReport.InsertPagebreak() completeReport.SaveAs("D:\Inetpub\wwwroot\CJISReport\CJISreportPage\" & strYear & "\monthlyList\" & strmonth & "\MajorProjects\All Reports.doc") completeReport.ActiveDocument.Close() newReport.ActiveDocument.Close() end if The if is to determine if it was the first report of the month. It will create the new report if so. There is different code in them cause I have been trying different things with each of them and unfortuenetly none of them work. It just tells me this error: Permission Denied. It tells me this for the line "end if". I have no Idea what this means. Any help would be really apprecieated. Thank you in advanced. Sokar ctl - alt - del if that dosen't work, bang your head on the keybord.

          S Offline
          S Offline
          Sage
          wrote on last edited by
          #4

          I am looking at the API here (Word.10) and under Word.Document I see a Merge feature. Sub Merge(FileName As String, [MergeTarget], [DetectFormatChanges], [UseFormattingFrom], [AddToRecentFiles]) Member of Word.Document This looks hopeful .. I am going to mess with it here for a sec and see if this helps you because it sure sounds like the type of function you are trying to execute. - Sage

          S S 2 Replies Last reply
          0
          • S Sage

            I am looking at the API here (Word.10) and under Word.Document I see a Merge feature. Sub Merge(FileName As String, [MergeTarget], [DetectFormatChanges], [UseFormattingFrom], [AddToRecentFiles]) Member of Word.Document This looks hopeful .. I am going to mess with it here for a sec and see if this helps you because it sure sounds like the type of function you are trying to execute. - Sage

            S Offline
            S Offline
            Sokar
            wrote on last edited by
            #5

            sounds interesting I will look into it as well. ctl - alt - del if that dosen't work, bang your head on the keybord.

            1 Reply Last reply
            0
            • S Sage

              I am looking at the API here (Word.10) and under Word.Document I see a Merge feature. Sub Merge(FileName As String, [MergeTarget], [DetectFormatChanges], [UseFormattingFrom], [AddToRecentFiles]) Member of Word.Document This looks hopeful .. I am going to mess with it here for a sec and see if this helps you because it sure sounds like the type of function you are trying to execute. - Sage

              S Offline
              S Offline
              Sage
              wrote on last edited by
              #6

              this document here might help you out... http://www.tek-tips.com/gviewthread.cfm/lev2/4/lev3/32/pid/708/qid/471051

              S 1 Reply Last reply
              0
              • S Sage

                this document here might help you out... http://www.tek-tips.com/gviewthread.cfm/lev2/4/lev3/32/pid/708/qid/471051

                S Offline
                S Offline
                Sage
                wrote on last edited by
                #7

                here we go::: strAppendFileName = "C:\MBrokers\Doc1.doc" strReadFile = "C:\MBrokers\Doc2.doc" Set WordApp = CreateObject("Word.Application") Set WordDoc = WordApp.Documents.Add() WordApp.Selection.InsertFile strAppendFileName WordApp.Selection.InsertFile strReadFile WordDoc.SaveAs "C:\MBrokers\Doc1.doc" WordDoc.Close WordApp.Quit Set WordDoc = Nothing Set WordApp = Nothing Response.write "

                Document Merged

                " & VbCrLF BUT !!!!! to make it work, I had to change IIS's security context to be administrator instead of IUSR_ but it works fine.....

                S 1 Reply Last reply
                0
                • S Sage

                  here we go::: strAppendFileName = "C:\MBrokers\Doc1.doc" strReadFile = "C:\MBrokers\Doc2.doc" Set WordApp = CreateObject("Word.Application") Set WordDoc = WordApp.Documents.Add() WordApp.Selection.InsertFile strAppendFileName WordApp.Selection.InsertFile strReadFile WordDoc.SaveAs "C:\MBrokers\Doc1.doc" WordDoc.Close WordApp.Quit Set WordDoc = Nothing Set WordApp = Nothing Response.write "

                  Document Merged

                  " & VbCrLF BUT !!!!! to make it work, I had to change IIS's security context to be administrator instead of IUSR_ but it works fine.....

                  S Offline
                  S Offline
                  Sokar
                  wrote on last edited by
                  #8

                  This looks great thank you. One question though. I bealive I am running on admin already but Its telling me permission denied: CreateObject. Is that Why you had to switch to admin status? If so how can I check if its set that way? I feel stupid asking but I asked around here and I got a big I don't know, but the general consencus was that I was already at that satus. Thanks again. Sokar ctl - alt - del if that dosen't work, bang your head on the keybord.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups