Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Word macro to vfp translation help
Message
From
29/12/1999 09:30:17
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
28/12/1999 15:37:16
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00309313
Message ID:
00309804
Views:
42
>>Todd-
>>
>>Sorry, but I don't know about the range method off-hand.
>
>That's ok. I found an ugly, ugly, ugly solution. But it works.
>
>I insert a space before I insert each table, then I insert the table. The next time thru the loop, I insert another space, and then the next table after that.
>
>Its working, I end up with extra spaces and the tables write in the wrong order (first table written is appearing at the bottom of the document.)
>
>I really appreciate your efforts. It seems like sometimes people don't have time to help. Or maybe I'm just suffering from post-christmas paranoia :-(
>
>-Todd


Hi Todd and Nancy,
You have done it already so consider this as an xmas gift :)
#include "wdconstants.h"
_CLIPTEXT = "WhatEverYouWantHereSeparateWithTabsForTableDataUsingApplicationDataToClipOrLowLevelI/O"
oWord = createobject("Word.Application")
WITH oWord
  .Documents.Open("c:\myPath\myTemplate.doc")
  lcMyBookMarkName = _VerifyBookMark(oWord,"DoesThisExist", "myTableHere")
  WITH toWord.ActiveDocument
    .Bookmarks(lcMyBookMarkName).Select
    WITH .Application.Selection
      .Collapse(wdCollapseEnd)  && Go to end of bookmark
      IF .Information(wdWithInTable) && If we're in a table
        .MoveEnd(wdTable)
        .Collapse(wdCollapseEnd)  && Get out of table
        .InsertParagraph()			&& Split table
        .Collapse(wdCollapseEnd)  && Clear selection
      ENDIF
      .Text = _cliptext           && Paste clip data
      lnWidth = tnPageColWidth / fcount()  && Calculate evenly distributed width
      loTable = .ConvertToTable(wdSeparateByTabs,,lnHeaders,lnWidth, ;
        wdTableFormatColorful2,,,,,,,.f.,,.f.) && Convert to table format Colorful 2
      .Find.Execute("~",,,,,,,,,chr(13),wdReplaceAll) && Restore memo para marks
      .Rows.AllowBreakAcrossPages = .f.  && Do not let row break if doesn't fit on same page
      .Collapse(wdCollapseEnd)
    ENDWITH
  ENDWITH
ENDWITH


*************************************************************************************
* Verify existence of bookmark - If not exist create one with tcTableName at EndOfDoc
*************************************************************************************
FUNCTION _VerifyBookMark
LPARAMETERS toWord, tcBookmarkName, tcTableName
IF type("tcBookmarkName") = "L" ;
    or ( type("tcBookmarkName") = "C" and empty(tcBookmarkName) ) ;
    or upper(tcBookmarkName) = "\ENDOFDOC" ;
    or !toWord.ActiveDocument.Bookmarks.Exists(tcBookmarkName)
  WITH toWord
    WITH .Selection
      .EndKey(wdStory)
      .InsertParagraphAfter()
    ENDWITH
    WITH .ActiveDocument
      IF !(type("tcBookmarkName") = "C" and ;
          !empty(tcBookmarkName) and ;
          !.Bookmarks.Exists(tcBookmarkName) )
        tcBookmarkName = tcTableName
      ENDIF
      IF !.Bookmarks.Exists(tcBookmarkName)
        .Bookmarks.Add(tcBookmarkName)
      ENDIF
    ENDWITH
  ENDWITH
ENDIF
RETURN tcBookmarkName
*************************************************************************************
* Verify existence of bookmark - If not exist create one with tcTableName at EndOfDoc
*************************************************************************************
The use of this routine is that you insert the table (in clipboard) to a bookmark if that exists or to endofdoc if that doesn't.
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