Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Word Auto: Delete after bookmark deletes bookmark
Message
From
22/04/2008 06:39:01
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
21/04/2008 10:40:21
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01311800
Message ID:
01312317
Views:
14
I see. The problem is we are selecting wdParagraph which selects entire para including the bookmark. Try this instead:
#include wdconstants.h
#Define NL Chr(13)+Chr(10)
*** set the LOCALEID to English
nlLocaleId=Sys(3004)		&& Save local id
=Sys(3006,1033)				&& We will be sending instructions in English

Use employee		&& test table
oWordDocument=Createobject("word.application")	&& Create word object
With oWordDocument
  .Documents.Add && Create a new doc
  .Visible = .T.
  .Activate
  .Activedocument.Bookmarks.Add('firstBookMark',.Activedocument.Range(0,0))
  .Selection.Collapse(wdCollapseEnd)
  .Selection.TypeText('ContractNo'+NL)
  Scan
    .Selection.TypeText('Employee Info Start.'+NL)
    .Selection.TypeText(Transform(emp_id)+NL+First_Name-(' '+Last_Name)+NL)
    .Selection.Collapse(wdCollapseEnd)
    lnRangeStart = .Selection.Range.End && set range for notes text and bookmark
    .Selection.TypeText(Nvl(notes,'')+NL+NL)
    lnRangeEnd   = .Selection.Range.End
    .Activedocument.Bookmarks.Add('b'+Padl(Recno(),2,'0'),.Activedocument.Range(lnRangeStart,lnRangeEnd))
  Endscan

  .Activedocument.Bookmarks('firstBookMark').Select

  .Selection.Collapse(wdCollapseEnd)
  If .Selection.End = 0
    .Selection.TypeText(NL)
  Endif
  .Selection.Collapse( wdCollapseEnd )
  .Selection.Expand( wdParagraph )
  .Selection.Delete

  If .Activedocument.Bookmarks.Exists('firstBookMark')
    .Activedocument.Bookmarks('firstBookMark').Select
    .Selection.Collapse(wdCollapseEnd)
    .Selection.TypeText('New Contract #.'+NL)
  Endif
Endwith

**** Set the LocaleId to the previous value
=Sys(3006,Val(nlLocaleId))
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform