Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a spreadsheet that the users fills in several fields, etc. then clicks a button to print a report. The report is a Word template file that has several bookmarks set where the data should be populated. I want to check for the existance of the bookmark in the document and update it if it exist in the document, (I have several reports and want to use the same procedure for all, but all reports will not have all the bookmarks). The code is listed below. My problem when the code runs, the template file is opened, but the bookmarks are not updated. The if statement checking for the bookmark runs and skips the bookmark as if it is not there. I can remove the if statement and the bookmark is updated. What have I done wrong in my coding.... Any help is appreciated.
Dim WordApp As Word.Application Set WordApp = New Word.Application Call Get_Excel_Info With WordApp .Visible = True .Documents.Add Template:=TemplatePath & TemplateToOpen, newtemplate:=False .Application.WindowState = wdWindowStateMaximize If .ActiveDocument.ProtectionType < wdNoProtection Then .ActiveDocument.Unprotect Password:="" End If If WordApp.ActiveDocument.Bookmarks.Exists(BM_License e) Then WordApp.ActiveDocument.Bookmarks("BM_Licensee").Ra nge.InsertAfter Txt_Licensee End If end with |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Without any testing at all, the first thing I would try is to enclose
the "BM_Licensee" in quotes in the If statement. In article , jag wrote: I have a spreadsheet that the users fills in several fields, etc. then clicks a button to print a report. The report is a Word template file that has several bookmarks set where the data should be populated. I want to check for the existance of the bookmark in the document and update it if it exist in the document, (I have several reports and want to use the same procedure for all, but all reports will not have all the bookmarks). The code is listed below. My problem when the code runs, the template file is opened, but the bookmarks are not updated. The if statement checking for the bookmark runs and skips the bookmark as if it is not there. I can remove the if statement and the bookmark is updated. What have I done wrong in my coding.... Any help is appreciated. Dim WordApp As Word.Application Set WordApp = New Word.Application Call Get_Excel_Info With WordApp .Visible = True .Documents.Add Template:=TemplatePath & TemplateToOpen, newtemplate:=False .Application.WindowState = wdWindowStateMaximize If .ActiveDocument.ProtectionType < wdNoProtection Then .ActiveDocument.Unprotect Password:="" End If If WordApp.ActiveDocument.Bookmarks.Exists(BM_License e) Then WordApp.ActiveDocument.Bookmarks("BM_Licensee").Ra nge.InsertAfter Txt_Licensee End If end with |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks, this was it.... Sorry I overlooked somthing as
simple as this... Thanks again... "JE McGimpsey" wrote: Without any testing at all, the first thing I would try is to enclose the "BM_Licensee" in quotes in the If statement. In article , jag wrote: I have a spreadsheet that the users fills in several fields, etc. then clicks a button to print a report. The report is a Word template file that has several bookmarks set where the data should be populated. I want to check for the existance of the bookmark in the document and update it if it exist in the document, (I have several reports and want to use the same procedure for all, but all reports will not have all the bookmarks). The code is listed below. My problem when the code runs, the template file is opened, but the bookmarks are not updated. The if statement checking for the bookmark runs and skips the bookmark as if it is not there. I can remove the if statement and the bookmark is updated. What have I done wrong in my coding.... Any help is appreciated. Dim WordApp As Word.Application Set WordApp = New Word.Application Call Get_Excel_Info With WordApp .Visible = True .Documents.Add Template:=TemplatePath & TemplateToOpen, newtemplate:=False .Application.WindowState = wdWindowStateMaximize If .ActiveDocument.ProtectionType < wdNoProtection Then .ActiveDocument.Unprotect Password:="" End If If WordApp.ActiveDocument.Bookmarks.Exists(BM_License e) Then WordApp.ActiveDocument.Bookmarks("BM_Licensee").Ra nge.InsertAfter Txt_Licensee End If end with |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How can I convert an Excel document to a Word Document | Setting up and Configuration of Excel | |||
Cross reference bookmarks in a Microsoft word document | Excel Discussion (Misc queries) | |||
convert excel document to word document (not a picture) | Excel Discussion (Misc queries) | |||
How do I convert Word document into an Excel document? | Excel Discussion (Misc queries) | |||
Using Word Bookmarks to read Text | Excel Programming |