![]() |
Word Library reference
Any idea what I have to change to make this work without have the MS Word
Object reference checked? OR is there a way to automatically select the word object library if the user does not have it checked? Set WordApp = CreateObject("word.application") 'open Word session WordApp.Visible = True 'Word visible during operation WordApp.Activate Set WordDoc = WordApp.Documents.Open(file_path) 'open Word doc On Error Resume Next With WordDoc.Content.Find With .Replacement End With .Execute findtext:="<release plan status", ReplaceWith:="Initial", _ Replace:=wdReplaceAll .Execute findtext:="<project/RIA ", ReplaceWith:="Project", _ Replace:=wdReplaceAll .Execute findtext:="<project#", ReplaceWith:=strProjNum & " ", _ Replace:=wdReplaceAll .Execute findtext:="<project name - or - <RIA name", _ ReplaceWith:=" " & strProjName, Replace:=wdReplaceAll .Execute findtext:="<mm/dd/yyyy hh:mm A ", ReplaceWith:=strRlsDate, _ Replace:=wdReplaceAll End With WordDoc.Tables(1).Rows(2).Range.Font.Color = wdColorBlue WordDoc.Tables(1).Rows(2).Range.ParagraphFormat.Al ignment = wdAlignParagraphCenter WordDoc.Tables(1).cell(2, 1).Range.text = "P & C Property Systems" WordDoc.Tables(2).Rows(2).Range.Font.Color = wdColorBlue WordDoc.Tables(2).cell(2, 1).Range.text = "1.0" WordDoc.Tables(2).cell(2, 2).Range.text = Date WordDoc.Tables(2).cell(2, 3).Range.text = "Created Document" WordDoc.Tables(2).cell(2, 4).Range.Font.Color = wdColorAutomatic On Error GoTo Err_WordDocs |
Word Library reference
You can use Late binding
Example to print a word doc Sub test() Dim WD As Object Set WD = CreateObject("Word.Application") WD.Documents.Open ("C:\ron.doc") WD.ActiveDocument.PrintOut Background:=False WD.ActiveDocument.Close WD.Quit Set WD = Nothing End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "Shawn G." wrote in message ... Any idea what I have to change to make this work without have the MS Word Object reference checked? OR is there a way to automatically select the word object library if the user does not have it checked? Set WordApp = CreateObject("word.application") 'open Word session WordApp.Visible = True 'Word visible during operation WordApp.Activate Set WordDoc = WordApp.Documents.Open(file_path) 'open Word doc On Error Resume Next With WordDoc.Content.Find With .Replacement End With .Execute findtext:="<release plan status", ReplaceWith:="Initial", _ Replace:=wdReplaceAll .Execute findtext:="<project/RIA ", ReplaceWith:="Project", _ Replace:=wdReplaceAll .Execute findtext:="<project#", ReplaceWith:=strProjNum & " ", _ Replace:=wdReplaceAll .Execute findtext:="<project name - or - <RIA name", _ ReplaceWith:=" " & strProjName, Replace:=wdReplaceAll .Execute findtext:="<mm/dd/yyyy hh:mm A ", ReplaceWith:=strRlsDate, _ Replace:=wdReplaceAll End With WordDoc.Tables(1).Rows(2).Range.Font.Color = wdColorBlue WordDoc.Tables(1).Rows(2).Range.ParagraphFormat.Al ignment = wdAlignParagraphCenter WordDoc.Tables(1).cell(2, 1).Range.text = "P & C Property Systems" WordDoc.Tables(2).Rows(2).Range.Font.Color = wdColorBlue WordDoc.Tables(2).cell(2, 1).Range.text = "1.0" WordDoc.Tables(2).cell(2, 2).Range.text = Date WordDoc.Tables(2).cell(2, 3).Range.text = "Created Document" WordDoc.Tables(2).cell(2, 4).Range.Font.Color = wdColorAutomatic On Error GoTo Err_WordDocs |
Word Library reference
for constants defined in the MS Word Object reference such as
wdReplaceAll you would have to use the actual value they represent. In this case, 2 ? wdReplaceAll 2 ? wdColorBlue 16711680 ? wdColorAutomatic -16777216 Those are the ones I saw skimming through the code. -- Regards, Tom Ogilvy "Shawn G." wrote in message ... Any idea what I have to change to make this work without have the MS Word Object reference checked? OR is there a way to automatically select the word object library if the user does not have it checked? Set WordApp = CreateObject("word.application") 'open Word session WordApp.Visible = True 'Word visible during operation WordApp.Activate Set WordDoc = WordApp.Documents.Open(file_path) 'open Word doc On Error Resume Next With WordDoc.Content.Find With .Replacement End With .Execute findtext:="<release plan status", ReplaceWith:="Initial", _ Replace:=wdReplaceAll .Execute findtext:="<project/RIA ", ReplaceWith:="Project", _ Replace:=wdReplaceAll .Execute findtext:="<project#", ReplaceWith:=strProjNum & " ", _ Replace:=wdReplaceAll .Execute findtext:="<project name - or - <RIA name", _ ReplaceWith:=" " & strProjName, Replace:=wdReplaceAll .Execute findtext:="<mm/dd/yyyy hh:mm A ", ReplaceWith:=strRlsDate, _ Replace:=wdReplaceAll End With WordDoc.Tables(1).Rows(2).Range.Font.Color = wdColorBlue WordDoc.Tables(1).Rows(2).Range.ParagraphFormat.Al ignment = wdAlignParagraphCenter WordDoc.Tables(1).cell(2, 1).Range.text = "P & C Property Systems" WordDoc.Tables(2).Rows(2).Range.Font.Color = wdColorBlue WordDoc.Tables(2).cell(2, 1).Range.text = "1.0" WordDoc.Tables(2).cell(2, 2).Range.text = Date WordDoc.Tables(2).cell(2, 3).Range.text = "Created Document" WordDoc.Tables(2).cell(2, 4).Range.Font.Color = wdColorAutomatic On Error GoTo Err_WordDocs |
Word Library reference
hmmmm,
he is using late binding. His problem is with the constants not being defined because he is using late binding - at least in my opinion. -- Regards, Tom Ogilvy "Ron de Bruin" wrote in message ... You can use Late binding Example to print a word doc Sub test() Dim WD As Object Set WD = CreateObject("Word.Application") WD.Documents.Open ("C:\ron.doc") WD.ActiveDocument.PrintOut Background:=False WD.ActiveDocument.Close WD.Quit Set WD = Nothing End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "Shawn G." wrote in message ... Any idea what I have to change to make this work without have the MS Word Object reference checked? OR is there a way to automatically select the word object library if the user does not have it checked? Set WordApp = CreateObject("word.application") 'open Word session WordApp.Visible = True 'Word visible during operation WordApp.Activate Set WordDoc = WordApp.Documents.Open(file_path) 'open Word doc On Error Resume Next With WordDoc.Content.Find With .Replacement End With .Execute findtext:="<release plan status", ReplaceWith:="Initial", _ Replace:=wdReplaceAll .Execute findtext:="<project/RIA ", ReplaceWith:="Project", _ Replace:=wdReplaceAll .Execute findtext:="<project#", ReplaceWith:=strProjNum & " ", _ Replace:=wdReplaceAll .Execute findtext:="<project name - or - <RIA name", _ ReplaceWith:=" " & strProjName, Replace:=wdReplaceAll .Execute findtext:="<mm/dd/yyyy hh:mm A ", ReplaceWith:=strRlsDate, _ Replace:=wdReplaceAll End With WordDoc.Tables(1).Rows(2).Range.Font.Color = wdColorBlue WordDoc.Tables(1).Rows(2).Range.ParagraphFormat.Al ignment = wdAlignParagraphCenter WordDoc.Tables(1).cell(2, 1).Range.text = "P & C Property Systems" WordDoc.Tables(2).Rows(2).Range.Font.Color = wdColorBlue WordDoc.Tables(2).cell(2, 1).Range.text = "1.0" WordDoc.Tables(2).cell(2, 2).Range.text = Date WordDoc.Tables(2).cell(2, 3).Range.text = "Created Document" WordDoc.Tables(2).cell(2, 4).Range.Font.Color = wdColorAutomatic On Error GoTo Err_WordDocs |
Word Library reference
Where can I find this list of codes????
"Tom Ogilvy" wrote: for constants defined in the MS Word Object reference such as wdReplaceAll you would have to use the actual value they represent. In this case, 2 ? wdReplaceAll 2 ? wdColorBlue 16711680 ? wdColorAutomatic -16777216 Those are the ones I saw skimming through the code. -- Regards, Tom Ogilvy "Shawn G." wrote in message ... Any idea what I have to change to make this work without have the MS Word Object reference checked? OR is there a way to automatically select the word object library if the user does not have it checked? Set WordApp = CreateObject("word.application") 'open Word session WordApp.Visible = True 'Word visible during operation WordApp.Activate Set WordDoc = WordApp.Documents.Open(file_path) 'open Word doc On Error Resume Next With WordDoc.Content.Find With .Replacement End With .Execute findtext:="<release plan status", ReplaceWith:="Initial", _ Replace:=wdReplaceAll .Execute findtext:="<project/RIA ", ReplaceWith:="Project", _ Replace:=wdReplaceAll .Execute findtext:="<project#", ReplaceWith:=strProjNum & " ", _ Replace:=wdReplaceAll .Execute findtext:="<project name - or - <RIA name", _ ReplaceWith:=" " & strProjName, Replace:=wdReplaceAll .Execute findtext:="<mm/dd/yyyy hh:mm A ", ReplaceWith:=strRlsDate, _ Replace:=wdReplaceAll End With WordDoc.Tables(1).Rows(2).Range.Font.Color = wdColorBlue WordDoc.Tables(1).Rows(2).Range.ParagraphFormat.Al ignment = wdAlignParagraphCenter WordDoc.Tables(1).cell(2, 1).Range.text = "P & C Property Systems" WordDoc.Tables(2).Rows(2).Range.Font.Color = wdColorBlue WordDoc.Tables(2).cell(2, 1).Range.text = "1.0" WordDoc.Tables(2).cell(2, 2).Range.text = Date WordDoc.Tables(2).cell(2, 3).Range.text = "Created Document" WordDoc.Tables(2).cell(2, 4).Range.Font.Color = wdColorAutomatic On Error GoTo Err_WordDocs |
Word Library reference
Yes, I see
-- Regards Ron de Bruin http://www.rondebruin.nl "Tom Ogilvy" wrote in message ... hmmmm, he is using late binding. His problem is with the constants not being defined because he is using late binding - at least in my opinion. -- Regards, Tom Ogilvy "Ron de Bruin" wrote in message ... You can use Late binding Example to print a word doc Sub test() Dim WD As Object Set WD = CreateObject("Word.Application") WD.Documents.Open ("C:\ron.doc") WD.ActiveDocument.PrintOut Background:=False WD.ActiveDocument.Close WD.Quit Set WD = Nothing End Sub -- Regards Ron de Bruin http://www.rondebruin.nl "Shawn G." wrote in message ... Any idea what I have to change to make this work without have the MS Word Object reference checked? OR is there a way to automatically select the word object library if the user does not have it checked? Set WordApp = CreateObject("word.application") 'open Word session WordApp.Visible = True 'Word visible during operation WordApp.Activate Set WordDoc = WordApp.Documents.Open(file_path) 'open Word doc On Error Resume Next With WordDoc.Content.Find With .Replacement End With .Execute findtext:="<release plan status", ReplaceWith:="Initial", _ Replace:=wdReplaceAll .Execute findtext:="<project/RIA ", ReplaceWith:="Project", _ Replace:=wdReplaceAll .Execute findtext:="<project#", ReplaceWith:=strProjNum & " ", _ Replace:=wdReplaceAll .Execute findtext:="<project name - or - <RIA name", _ ReplaceWith:=" " & strProjName, Replace:=wdReplaceAll .Execute findtext:="<mm/dd/yyyy hh:mm A ", ReplaceWith:=strRlsDate, _ Replace:=wdReplaceAll End With WordDoc.Tables(1).Rows(2).Range.Font.Color = wdColorBlue WordDoc.Tables(1).Rows(2).Range.ParagraphFormat.Al ignment = wdAlignParagraphCenter WordDoc.Tables(1).cell(2, 1).Range.text = "P & C Property Systems" WordDoc.Tables(2).Rows(2).Range.Font.Color = wdColorBlue WordDoc.Tables(2).cell(2, 1).Range.text = "1.0" WordDoc.Tables(2).cell(2, 2).Range.text = Date WordDoc.Tables(2).cell(2, 3).Range.text = "Created Document" WordDoc.Tables(2).cell(2, 4).Range.Font.Color = wdColorAutomatic On Error GoTo Err_WordDocs |
Word Library reference
Tom use the Immediate window in the VBA editor (View menu or Ctrl-g)
But if you use the Object browser you can see them also -- Regards Ron de Bruin http://www.rondebruin.nl "Shawn G." wrote in message ... Where can I find this list of codes???? "Tom Ogilvy" wrote: for constants defined in the MS Word Object reference such as wdReplaceAll you would have to use the actual value they represent. In this case, 2 ? wdReplaceAll 2 ? wdColorBlue 16711680 ? wdColorAutomatic -16777216 Those are the ones I saw skimming through the code. -- Regards, Tom Ogilvy "Shawn G." wrote in message ... Any idea what I have to change to make this work without have the MS Word Object reference checked? OR is there a way to automatically select the word object library if the user does not have it checked? Set WordApp = CreateObject("word.application") 'open Word session WordApp.Visible = True 'Word visible during operation WordApp.Activate Set WordDoc = WordApp.Documents.Open(file_path) 'open Word doc On Error Resume Next With WordDoc.Content.Find With .Replacement End With .Execute findtext:="<release plan status", ReplaceWith:="Initial", _ Replace:=wdReplaceAll .Execute findtext:="<project/RIA ", ReplaceWith:="Project", _ Replace:=wdReplaceAll .Execute findtext:="<project#", ReplaceWith:=strProjNum & " ", _ Replace:=wdReplaceAll .Execute findtext:="<project name - or - <RIA name", _ ReplaceWith:=" " & strProjName, Replace:=wdReplaceAll .Execute findtext:="<mm/dd/yyyy hh:mm A ", ReplaceWith:=strRlsDate, _ Replace:=wdReplaceAll End With WordDoc.Tables(1).Rows(2).Range.Font.Color = wdColorBlue WordDoc.Tables(1).Rows(2).Range.ParagraphFormat.Al ignment = wdAlignParagraphCenter WordDoc.Tables(1).cell(2, 1).Range.text = "P & C Property Systems" WordDoc.Tables(2).Rows(2).Range.Font.Color = wdColorBlue WordDoc.Tables(2).cell(2, 1).Range.text = "1.0" WordDoc.Tables(2).cell(2, 2).Range.text = Date WordDoc.Tables(2).cell(2, 3).Range.text = "Created Document" WordDoc.Tables(2).cell(2, 4).Range.Font.Color = wdColorAutomatic On Error GoTo Err_WordDocs |
Word Library reference
but either method requires you create the reference to the Work object
library for determining their values. If you test you code with the reference in place, it will hide any that you miss because then the constants are defined. Just some thoughts. -- Regards, Tom Ogilvy "Ron de Bruin" wrote in message ... Tom use the Immediate window in the VBA editor (View menu or Ctrl-g) But if you use the Object browser you can see them also -- Regards Ron de Bruin http://www.rondebruin.nl "Shawn G." wrote in message ... Where can I find this list of codes???? "Tom Ogilvy" wrote: for constants defined in the MS Word Object reference such as wdReplaceAll you would have to use the actual value they represent. In this case, 2 ? wdReplaceAll 2 ? wdColorBlue 16711680 ? wdColorAutomatic -16777216 Those are the ones I saw skimming through the code. -- Regards, Tom Ogilvy "Shawn G." wrote in message ... Any idea what I have to change to make this work without have the MS Word Object reference checked? OR is there a way to automatically select the word object library if the user does not have it checked? Set WordApp = CreateObject("word.application") 'open Word session WordApp.Visible = True 'Word visible during operation WordApp.Activate Set WordDoc = WordApp.Documents.Open(file_path) 'open Word doc On Error Resume Next With WordDoc.Content.Find With .Replacement End With .Execute findtext:="<release plan status", ReplaceWith:="Initial", _ Replace:=wdReplaceAll .Execute findtext:="<project/RIA ", ReplaceWith:="Project", _ Replace:=wdReplaceAll .Execute findtext:="<project#", ReplaceWith:=strProjNum & " ", _ Replace:=wdReplaceAll .Execute findtext:="<project name - or - <RIA name", _ ReplaceWith:=" " & strProjName, Replace:=wdReplaceAll .Execute findtext:="<mm/dd/yyyy hh:mm A ", ReplaceWith:=strRlsDate, _ Replace:=wdReplaceAll End With WordDoc.Tables(1).Rows(2).Range.Font.Color = wdColorBlue WordDoc.Tables(1).Rows(2).Range.ParagraphFormat.Al ignment = wdAlignParagraphCenter WordDoc.Tables(1).cell(2, 1).Range.text = "P & C Property Systems" WordDoc.Tables(2).Rows(2).Range.Font.Color = wdColorBlue WordDoc.Tables(2).cell(2, 1).Range.text = "1.0" WordDoc.Tables(2).cell(2, 2).Range.text = Date WordDoc.Tables(2).cell(2, 3).Range.text = "Created Document" WordDoc.Tables(2).cell(2, 4).Range.Font.Color = wdColorAutomatic On Error GoTo Err_WordDocs |
Word Library reference
You guys are GREAT!!!!
ThankYou, Don't know how to use the immediate window but object browser did the trick! "Ron de Bruin" wrote: Tom use the Immediate window in the VBA editor (View menu or Ctrl-g) But if you use the Object browser you can see them also -- Regards Ron de Bruin http://www.rondebruin.nl "Shawn G." wrote in message ... Where can I find this list of codes???? "Tom Ogilvy" wrote: for constants defined in the MS Word Object reference such as wdReplaceAll you would have to use the actual value they represent. In this case, 2 ? wdReplaceAll 2 ? wdColorBlue 16711680 ? wdColorAutomatic -16777216 Those are the ones I saw skimming through the code. -- Regards, Tom Ogilvy "Shawn G." wrote in message ... Any idea what I have to change to make this work without have the MS Word Object reference checked? OR is there a way to automatically select the word object library if the user does not have it checked? Set WordApp = CreateObject("word.application") 'open Word session WordApp.Visible = True 'Word visible during operation WordApp.Activate Set WordDoc = WordApp.Documents.Open(file_path) 'open Word doc On Error Resume Next With WordDoc.Content.Find With .Replacement End With .Execute findtext:="<release plan status", ReplaceWith:="Initial", _ Replace:=wdReplaceAll .Execute findtext:="<project/RIA ", ReplaceWith:="Project", _ Replace:=wdReplaceAll .Execute findtext:="<project#", ReplaceWith:=strProjNum & " ", _ Replace:=wdReplaceAll .Execute findtext:="<project name - or - <RIA name", _ ReplaceWith:=" " & strProjName, Replace:=wdReplaceAll .Execute findtext:="<mm/dd/yyyy hh:mm A ", ReplaceWith:=strRlsDate, _ Replace:=wdReplaceAll End With WordDoc.Tables(1).Rows(2).Range.Font.Color = wdColorBlue WordDoc.Tables(1).Rows(2).Range.ParagraphFormat.Al ignment = wdAlignParagraphCenter WordDoc.Tables(1).cell(2, 1).Range.text = "P & C Property Systems" WordDoc.Tables(2).Rows(2).Range.Font.Color = wdColorBlue WordDoc.Tables(2).cell(2, 1).Range.text = "1.0" WordDoc.Tables(2).cell(2, 2).Range.text = Date WordDoc.Tables(2).cell(2, 3).Range.text = "Created Document" WordDoc.Tables(2).cell(2, 4).Range.Font.Color = wdColorAutomatic On Error GoTo Err_WordDocs |
All times are GMT +1. The time now is 03:39 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com