Hi everyone,
I am automating MS Word 97 SR-2 from VFP 6. Everything is working fine
except for two things I need to do and cannot figure it out how:
1. How to determine if a document contains a macro.
2. How do I stop macros from running when I open the doc.
I have been at the MS site going through the Office developer documentation
and cannot find anything on this.
The problem is I need to scan these documents and determine what types of
objects are in them (hyperlinks, images, macros, document version etc...).
If I try to open the doc using Word it informs me the document contains
macros and lets me determine if I want to run them or not. But if I open it
using automation then the macro runs with no warning. Since I have no idea
who is sending these documents I would prefer not to run the macros. I
tried setting oWord.DisplayAlerts = -1 (Show all alerts) but that ddoes
nothing for macros. Any ideas?
Thanks
Tom
Shop Safely Online Without a Credit Card
Is your doc built on a template. You may need to adjust the paper size on
that or the default doc.
Allen
-----Original Message-----
From: profox@leafe.com [mailto:profox@leafe.com]On Behalf Of Andrew
Dewey
When I go to print a Document built in Word from Fox I'm getting an message
from Word that my margins are outside the printable boundaries. I get this
message even when oWord.DisplayAlerts = .F. The document prints fine. Is
there some other mechanism to turn the warning alert off? It's a bit of a
I'm trying to use amembers() to test for the existence of a custom style.
I try:
nstyles = amembers(aStyles,oDoc.Styles)
and I get a result of 0. Will amembers work with non-fox objects, and if
so, what am I doing wrong.
Many Thanks,
Andrew
PS
This is the code I use to add the style:
oBodyStyle = oDoc.Styles.ADD( "Body", 1 )
Andrew Dewey
Acadia Computer Corp. Bar Harbor, ME
andrew@acadiacomp.com
Author: Anders Altberg
Posted: 2001-05-15 00:35:54 Link
Not until VFP7. Patience.
-A
----- Original Message -----
From: "Andrew Dewey" <andrew@acadiacomp.com>
To: "Multiple recipients of ProFox" <profox@leafe.com>
Sent: Monday, May 14, 2001 6:42 PM
Subject: Word Automation - determining if style exists
> I'm trying to use amembers() to test for the existence of a custom style.
>
> I try:
>
> nstyles = amembers(aStyles,oDoc.Styles)
>
>
> and I get a result of 0. Will amembers work with non-fox objects, and if
> so, what am I doing wrong.
>
> Many Thanks,
>
> Andrew
>
> PS
>
> This is the code I use to add the style:
> oBodyStyle = oDoc.Styles.ADD( "Body", 1 )
> Andrew Dewey
> Acadia Computer Corp. Bar Harbor, ME
> andrew@acadiacomp.com
>
>
>
Author: Brian.Searle@indsys.ge.com
Posted: 2001-05-16 15:11:44 Link
Bill,
Sorry, I've never done anything with bookmarks.
Brian Searle
brian.searle@indsys.ge.com
> -----Original Message-----
> From: Bill - Work email [mailto:bill.coupe@welove.com]
> Sent: Wednesday, May 16, 2001 4:06 PM
> To: Multiple recipients of ProFox
> Subject: Word Automation/Bookmarks (was Word Headers)
>
>
> Brian -
>
> Do you have a method for identifying (so that you can cycle
> through them)
> all the bookmarks on a given document?
>
> Ideal would be a way to load them into an array from whatever
> container
> holds them in the document.
>
> Thanks,
>
> -Bill
>
Author: Bill - Work email
Posted: 2001-05-16 16:06:28 Link
Brian -
Do you have a method for identifying (so that you can cycle through them)
all the bookmarks on a given document?
Ideal would be a way to load them into an array from whatever container
holds them in the document.
Thanks,
-Bill
----- Original Message -----
From: <Brian.Searle@indsys.ge.com>
To: "Multiple recipients of ProFox" <profox@leafe.com>
Sent: Wednesday, May 16, 2001 1:27 PM
Subject: RE: Word Headers
> Ken,
>
> I spent a lot of time on an application using Word 97 last year. I know
how
> frustrating it can be to use the Object Browser in Word and convert VB
> constants to VFP equivalents.
>
> I've included some code to show how I set up a header for a first page
with a
> different one for the remaining pages.
>
> *-- Word header example
> oWord = CREATEOBJECT("Word.Application")
> oWord.CAPTION = "My Word Document"
> oDoc = oWord.documents.ADD()
> oWord.ActiveWindow.ActivePane.VIEW.TYPE = 3 && Set to page view
> oWord.VISIBLE = .T.
> oWord.WINDOWSTATE = 1
>
> *-- Set the page margins
> WITH oDoc.PageSetup
> .TopMargin = 20
> .BottomMargin = 40
> .LeftMargin = 57.5
> .RightMargin = 20
> ENDWITH
>
> *-- Set the header information for the top of each page
> oWord.ActiveWindow.ActivePane.VIEW.SeekView = 9
>
> WITH oWord.SELECTION
> .ParagraphFormat.TabStops.ClearAll
> .ParagraphFormat.ALIGNMENT = 0
> .ParagraphFormat.TabStops.ADD(380)
> .TypeText(CHR(13)+CHR(13)+CHR(13))
> .FONT.NAME = "Times New Roman"
> .FONT.SIZE = 16
> .FONT.BOLD = .T.
> .FONT.ITALIC = .T.
> .TypeText(CHR(9)+"My Logo")
> .HeaderFooter.Shapes.AddLine(58, 94, 461, 94)
> * .HeaderFooter.Shapes.AddPicture(sys(5)+"mylogo.gif")
> .TypeText(CHR(13))
> ENDWITH
>
> oWord.ActiveWindow.ActivePane.VIEW.SeekView = 0
> oWord.ActiveWindow.ActivePane.VIEW.SeekView = 9
>
> WITH oWord.SELECTION
> .PageSetup.DifferentFirstPageHeaderFooter = .T.
> .ParagraphFormat.TabStops.ClearAll
> .ParagraphFormat.ALIGNMENT = 0
> .ParagraphFormat.TabStops.ADD(380)
> .TypeText(CHR(13)+CHR(13)+CHR(13))
> .FONT.NAME = "Times New Roman"
> .FONT.SIZE = 16
> .FONT.BOLD = .T.
> .FONT.ITALIC = .T.
> .TypeText(CHR(9)+"My Logo")
> .HeaderFooter.Shapes.AddLine(58, 94, 461, 94)
> * .HeaderFooter.Shapes.AddPicture(sys(5)+"mylogo.gif")
> .TypeText(CHR(13))
> .FONT.SIZE = 8
> .FONT.BOLD = .F.
> .FONT.ITALIC = .F.
> .TypeText(CHR(13))
> .TypeText(CHR(9)+"First page info only")
> .TypeText(CHR(13))
> ENDWITH
>
> oWord.ActiveWindow.ActivePane.VIEW.SeekView = 0
>
> WITH oWord.SELECTION
> .InsertBreak(7)
> .TypeText(CHR(9)+"Some stuff on another page")
> ENDWITH
>
> In the case that it matters, this runs using VFP6 SP4 and Word 97 (it
works in
> 2000 as well).
> HTH
>
> Brian Searle
> brian.searle@indsys.ge.com
>
>
> > -----Original Message-----
> > From: Teague Ken Contr ESC/XP [mailto:Ken.Teague@hanscom.af.mil]
> > Sent: Wednesday, May 16, 2001 10:54 AM
> > To: Multiple recipients of ProFox
> > Subject: Word Headers
> >
> >
> >
> > In creating a word document via automation I need to create
> > one header for
> > the first page, then a different header for the subsequent
> > pages. Do anyone
> > have code that I can use as guide to create?
> >
> >
> > Ken.Teague@Hanscom.AF.MIL
> >
> >
> >
> >
> > >
>
>
Author: Cindy Winegarden
Posted: 2001-05-20 20:07:33 Link
Bill and Brian,
Forgive me if this has been answered already. There is a bookmarks
collection in the Word object model. Then you can use code like:
oWord = CREATEOBJECT([Word.Application])
oWord.Visible = .T.
oDocument = oWord.Documents.Add([MyDoc.DOC])
*!* Assume you've got some bookmarks in this document
FOR EACH oBookmark IN oDocument.Bookmarks
oBookmark.Select()
ENDFOR
Cindy Winegarden MCSD, MVP
cindy.winegarden@mvps.org
-----Original Message-----
From: profox@leafe.com [mailto:profox@leafe.com] On Behalf Of Bill -
Work email
Sent: Wednesday, May 16, 2001 4:06 PM
To: Multiple recipients of ProFox
Subject: Word Automation/Bookmarks (was Word Headers)
Brian -
Do you have a method for identifying (so that you can cycle through
them) all the bookmarks on a given document?
Ideal would be a way to load them into an array from whatever container
holds them in the document.
Thanks,
-Bill
----- Original Message -----
From: <Brian.Searle@indsys.ge.com>
To: "Multiple recipients of ProFox" <profox@leafe.com>
Sent: Wednesday, May 16, 2001 1:27 PM
Subject: RE: Word Headers
> Ken,
>
> I spent a lot of time on an application using Word 97 last year. I
> know
how
> frustrating it can be to use the Object Browser in Word and convert VB
> constants to VFP equivalents.
>
> I've included some code to show how I set up a header for a first page
with a
> different one for the remaining pages.
>
> *-- Word header example
> oWord = CREATEOBJECT("Word.Application")
> oWord.CAPTION = "My Word Document"
> oDoc = oWord.documents.ADD() oWord.ActiveWindow.ActivePane.VIEW.TYPE
> = 3 && Set to page view oWord.VISIBLE = .T.
> oWord.WINDOWSTATE = 1
>
> *-- Set the page margins
> WITH oDoc.PageSetup
> .TopMargin = 20
> .BottomMargin = 40
> .LeftMargin = 57.5
> .RightMargin = 20
> ENDWITH
>
> *-- Set the header information for the top of each page
> oWord.ActiveWindow.ActivePane.VIEW.SeekView = 9
>
> WITH oWord.SELECTION
> .ParagraphFormat.TabStops.ClearAll
> .ParagraphFormat.ALIGNMENT = 0
> .ParagraphFormat.TabStops.ADD(380)
> .TypeText(CHR(13)+CHR(13)+CHR(13))
> .FONT.NAME = "Times New Roman"
> .FONT.SIZE = 16
> .FONT.BOLD = .T.
> .FONT.ITALIC = .T.
> .TypeText(CHR(9)+"My Logo")
> .HeaderFooter.Shapes.AddLine(58, 94, 461, 94)
> * .HeaderFooter.Shapes.AddPicture(sys(5)+"mylogo.gif")
> .TypeText(CHR(13))
> ENDWITH
>
> oWord.ActiveWindow.ActivePane.VIEW.SeekView = 0
> oWord.ActiveWindow.ActivePane.VIEW.SeekView = 9
>
> WITH oWord.SELECTION .PageSetup.DifferentFirstPageHeaderFooter = .T.
> .ParagraphFormat.TabStops.ClearAll
> .ParagraphFormat.ALIGNMENT = 0
> .ParagraphFormat.TabStops.ADD(380)
> .TypeText(CHR(13)+CHR(13)+CHR(13))
> .FONT.NAME = "Times New Roman"
> .FONT.SIZE = 16
> .FONT.BOLD = .T.
> .FONT.ITALIC = .T.
> .TypeText(CHR(9)+"My Logo")
> .HeaderFooter.Shapes.AddLine(58, 94, 461, 94)
> * .HeaderFooter.Shapes.AddPicture(sys(5)+"mylogo.gif")
> .TypeText(CHR(13))
> .FONT.SIZE = 8
> .FONT.BOLD = .F.
> .FONT.ITALIC = .F.
> .TypeText(CHR(13))
> .TypeText(CHR(9)+"First page info only")
> .TypeText(CHR(13))
> ENDWITH
>
> oWord.ActiveWindow.ActivePane.VIEW.SeekView = 0
>
> WITH oWord.SELECTION
> .InsertBreak(7)
> .TypeText(CHR(9)+"Some stuff on another page")
> ENDWITH
>
> In the case that it matters, this runs using VFP6 SP4 and Word 97 (it
works in
> 2000 as well).
> HTH
>
> Brian Searle
> brian.searle@indsys.ge.com
>
>
> > -----Original Message-----
> > From: Teague Ken Contr ESC/XP [mailto:Ken.Teague@hanscom.af.mil]
> > Sent: Wednesday, May 16, 2001 10:54 AM
> > To: Multiple recipients of ProFox
> > Subject: Word Headers
> >
> >
> >
> > In creating a word document via automation I need to create one
> > header for the first page, then a different header for the
> > subsequent pages. Do anyone
> > have code that I can use as guide to create?
> >
> >
> > Ken.Teague@Hanscom.AF.MIL
Author: Bill Anderson
Posted: 2001-05-20 21:39:08 Link
I've used brackets as character delimiters for 13 years. Works just
fine, and it avoids conflicts with single and double quotes.
Bill Anderson
John Koziol wrote:
> Hmmm....OK, if it works what-the-hell!
Author: John Koziol
Posted: 2001-05-20 22:32:25 Link
OK, I'm gonna assume there is a compelling reason for the brackets in place
of the normal quotes.... ;-)
-----Original Message-----
From: profox@leafe.com [mailto:profox@leafe.com]On Behalf Of Cindy
Winegarden
Sent: Sunday, May 20, 2001 8:08 PM
To: Multiple recipients of ProFox
Subject: RE: Word Automation/Bookmarks (was Word Headers)
Bill and Brian,
Forgive me if this has been answered already. There is a bookmarks
collection in the Word object model. Then you can use code like:
oWord = CREATEOBJECT([Word.Application])
oWord.Visible = .T.
oDocument = oWord.Documents.Add([MyDoc.DOC])
*!* Assume you've got some bookmarks in this document
FOR EACH oBookmark IN oDocument.Bookmarks
oBookmark.Select()
ENDFOR
Cindy Winegarden MCSD, MVP
cindy.winegarden@mvps.org
-----Original Message-----
From: profox@leafe.com [mailto:profox@leafe.com] On Behalf Of Bill -
Work email
Sent: Wednesday, May 16, 2001 4:06 PM
To: Multiple recipients of ProFox
Subject: Word Automation/Bookmarks (was Word Headers)
Brian -
Do you have a method for identifying (so that you can cycle through
them) all the bookmarks on a given document?
Ideal would be a way to load them into an array from whatever container
holds them in the document.
Thanks,
-Bill
----- Original Message -----
From: <Brian.Searle@indsys.ge.com>
To: "Multiple recipients of ProFox" <profox@leafe.com>
Sent: Wednesday, May 16, 2001 1:27 PM
Subject: RE: Word Headers
> Ken,
>
> I spent a lot of time on an application using Word 97 last year. I
> know
how
> frustrating it can be to use the Object Browser in Word and convert VB
> constants to VFP equivalents.
>
> I've included some code to show how I set up a header for a first page
with a
> different one for the remaining pages.
>
> *-- Word header example
> oWord = CREATEOBJECT("Word.Application")
> oWord.CAPTION = "My Word Document"
> oDoc = oWord.documents.ADD() oWord.ActiveWindow.ActivePane.VIEW.TYPE
> = 3 && Set to page view oWord.VISIBLE = .T.
> oWord.WINDOWSTATE = 1
>
> *-- Set the page margins
> WITH oDoc.PageSetup
> .TopMargin = 20
> .BottomMargin = 40
> .LeftMargin = 57.5
> .RightMargin = 20
> ENDWITH
>
> *-- Set the header information for the top of each page
> oWord.ActiveWindow.ActivePane.VIEW.SeekView = 9
>
> WITH oWord.SELECTION
> .ParagraphFormat.TabStops.ClearAll
> .ParagraphFormat.ALIGNMENT = 0
> .ParagraphFormat.TabStops.ADD(380)
> .TypeText(CHR(13)+CHR(13)+CHR(13))
> .FONT.NAME = "Times New Roman"
> .FONT.SIZE = 16
> .FONT.BOLD = .T.
> .FONT.ITALIC = .T.
> .TypeText(CHR(9)+"My Logo")
> .HeaderFooter.Shapes.AddLine(58, 94, 461, 94)
> * .HeaderFooter.Shapes.AddPicture(sys(5)+"mylogo.gif")
> .TypeText(CHR(13))
> ENDWITH
>
> oWord.ActiveWindow.ActivePane.VIEW.SeekView = 0
> oWord.ActiveWindow.ActivePane.VIEW.SeekView = 9
>
> WITH oWord.SELECTION .PageSetup.DifferentFirstPageHeaderFooter = .T.
> .ParagraphFormat.TabStops.ClearAll
> .ParagraphFormat.ALIGNMENT = 0
> .ParagraphFormat.TabStops.ADD(380)
> .TypeText(CHR(13)+CHR(13)+CHR(13))
> .FONT.NAME = "Times New Roman"
> .FONT.SIZE = 16
> .FONT.BOLD = .T.
> .FONT.ITALIC = .T.
> .TypeText(CHR(9)+"My Logo")
> .HeaderFooter.Shapes.AddLine(58, 94, 461, 94)
> * .HeaderFooter.Shapes.AddPicture(sys(5)+"mylogo.gif")
> .TypeText(CHR(13))
> .FONT.SIZE = 8
> .FONT.BOLD = .F.
> .FONT.ITALIC = .F.
> .TypeText(CHR(13))
> .TypeText(CHR(9)+"First page info only")
> .TypeText(CHR(13))
> ENDWITH
>
> oWord.ActiveWindow.ActivePane.VIEW.SeekView = 0
>
> WITH oWord.SELECTION
> .InsertBreak(7)
> .TypeText(CHR(9)+"Some stuff on another page")
> ENDWITH
>
> In the case that it matters, this runs using VFP6 SP4 and Word 97 (it
works in
> 2000 as well).
> HTH
>
> Brian Searle
> brian.searle@indsys.ge.com
>
>
> > -----Original Message-----
> > From: Teague Ken Contr ESC/XP [mailto:Ken.Teague@hanscom.af.mil]
> > Sent: Wednesday, May 16, 2001 10:54 AM
> > To: Multiple recipients of ProFox
> > Subject: Word Headers
> >
> >
> >
> > In creating a word document via automation I need to create one
> > header for the first page, then a different header for the
> > subsequent pages. Do anyone
> > have code that I can use as guide to create?
> >
> >
> > Ken.Teague@Hanscom.AF.MIL
Author: Cindy Winegarden
Posted: 2001-05-20 22:56:16 Link
JK,
I do a lot of SQL Pass-through involving the use of internal quotes.
Brackets solve so many problems that I began using them everywhere.
Consider the following:
cMySQL = ;
[SELECT * FROM MyTable ] + ;
[WHERE MyField = "Adam's Apple" ]
Cindy Winegarden MCSD, MVP
cindy.winegarden@mvps.org
-----Original Message-----
From: profox@leafe.com [mailto:profox@leafe.com] On Behalf Of John
Koziol
Sent: Sunday, May 20, 2001 10:32 PM
To: Multiple recipients of ProFox
Subject: RE: Word Automation/Bookmarks (was Word Headers)
OK, I'm gonna assume there is a compelling reason for the brackets in
place of the normal quotes.... ;-)
-----Original Message-----
From: profox@leafe.com [mailto:profox@leafe.com]On Behalf Of Cindy
Winegarden
Sent: Sunday, May 20, 2001 8:08 PM
To: Multiple recipients of ProFox
Subject: RE: Word Automation/Bookmarks (was Word Headers)
Bill and Brian,
Forgive me if this has been answered already. There is a bookmarks
collection in the Word object model. Then you can use code like:
oWord = CREATEOBJECT([Word.Application])
oWord.Visible = .T.
oDocument = oWord.Documents.Add([MyDoc.DOC])
*!* Assume you've got some bookmarks in this document
FOR EACH oBookmark IN oDocument.Bookmarks
oBookmark.Select()
ENDFOR
Cindy Winegarden MCSD, MVP
cindy.winegarden@mvps.org
-----Original Message-----
From: profox@leafe.com [mailto:profox@leafe.com] On Behalf Of Bill -
Work email
Sent: Wednesday, May 16, 2001 4:06 PM
To: Multiple recipients of ProFox
Subject: Word Automation/Bookmarks (was Word Headers)
Brian -
Do you have a method for identifying (so that you can cycle through
them) all the bookmarks on a given document?
Ideal would be a way to load them into an array from whatever container
holds them in the document.
Thanks,
-Bill
----- Original Message -----
From: <Brian.Searle@indsys.ge.com>
To: "Multiple recipients of ProFox" <profox@leafe.com>
Sent: Wednesday, May 16, 2001 1:27 PM
Subject: RE: Word Headers
> Ken,
>
> I spent a lot of time on an application using Word 97 last year. I
> know
how
> frustrating it can be to use the Object Browser in Word and convert VB
> constants to VFP equivalents.
>
> I've included some code to show how I set up a header for a first page
with a
> different one for the remaining pages.
>
> *-- Word header example
> oWord = CREATEOBJECT("Word.Application")
> oWord.CAPTION = "My Word Document"
> oDoc = oWord.documents.ADD() oWord.ActiveWindow.ActivePane.VIEW.TYPE
> = 3 && Set to page view oWord.VISIBLE = .T.
> oWord.WINDOWSTATE = 1
>
> *-- Set the page margins
> WITH oDoc.PageSetup
> .TopMargin = 20
> .BottomMargin = 40
> .LeftMargin = 57.5
> .RightMargin = 20
> ENDWITH
>
> *-- Set the header information for the top of each page
> oWord.ActiveWindow.ActivePane.VIEW.SeekView = 9
>
> WITH oWord.SELECTION
> .ParagraphFormat.TabStops.ClearAll
> .ParagraphFormat.ALIGNMENT = 0
> .ParagraphFormat.TabStops.ADD(380)
> .TypeText(CHR(13)+CHR(13)+CHR(13))
> .FONT.NAME = "Times New Roman"
> .FONT.SIZE = 16
> .FONT.BOLD = .T.
> .FONT.ITALIC = .T.
> .TypeText(CHR(9)+"My Logo")
> .HeaderFooter.Shapes.AddLine(58, 94, 461, 94)
> * .HeaderFooter.Shapes.AddPicture(sys(5)+"mylogo.gif")
> .TypeText(CHR(13))
> ENDWITH
>
> oWord.ActiveWindow.ActivePane.VIEW.SeekView = 0
> oWord.ActiveWindow.ActivePane.VIEW.SeekView = 9
>
> WITH oWord.SELECTION .PageSetup.DifferentFirstPageHeaderFooter = .T.
> .ParagraphFormat.TabStops.ClearAll
> .ParagraphFormat.ALIGNMENT = 0
> .ParagraphFormat.TabStops.ADD(380)
> .TypeText(CHR(13)+CHR(13)+CHR(13))
> .FONT.NAME = "Times New Roman"
> .FONT.SIZE = 16
> .FONT.BOLD = .T.
> .FONT.ITALIC = .T.
> .TypeText(CHR(9)+"My Logo")
> .HeaderFooter.Shapes.AddLine(58, 94, 461, 94)
> * .HeaderFooter.Shapes.AddPicture(sys(5)+"mylogo.gif")
> .TypeText(CHR(13))
> .FONT.SIZE = 8
> .FONT.BOLD = .F.
> .FONT.ITALIC = .F.
> .TypeText(CHR(13))
> .TypeText(CHR(9)+"First page info only")
> .TypeText(CHR(13))
> ENDWITH
>
> oWord.ActiveWindow.ActivePane.VIEW.SeekView = 0
>
> WITH oWord.SELECTION
> .InsertBreak(7)
> .TypeText(CHR(9)+"Some stuff on another page")
> ENDWITH
>
> In the case that it matters, this runs using VFP6 SP4 and Word 97 (it
works in
> 2000 as well).
> HTH
>
> Brian Searle
> brian.searle@indsys.ge.com
>
>
> > -----Original Message-----
> > From: Teague Ken Contr ESC/XP [mailto:Ken.Teague@hanscom.af.mil]
> > Sent: Wednesday, May 16, 2001 10:54 AM
> > To: Multiple recipients of ProFox
> > Subject: Word Headers
> >
> >
> >
> > In creating a word document via automation I need to create one
> > header for the first page, then a different header for the
> > subsequent pages. Do anyone have code that I can use as guide to
> > create?
> >
> >
> > Ken.Teague@Hanscom.AF.MIL