#1   Report Post  
Posted to microsoft.public.word.docmanagement
Kerry Kerry is offline
external usenet poster
 
Posts: 45
Default Macro doesn't work

I have a macro which saves my Word doc as a pdf based on words within the
document itself. Sometimes I get an error and the macro stops on the
following line:

ActiveDocument.ExportAsFixedFormat OutputFileName:=sFileName, _
ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False,
OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, To:=1, _
Item:=wdExportDocumentContent, IncludeDocProps:=False, KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
BitmapMissingFonts:=True, UseISO19005_1:=False

sFileName is a string

If I close out of all my Office apps (Outlook, Word 2007) then reopen Word
and invoke the macro right away, it will work beautifully. I don't know if
it has to do with the other apps or not, but if I restart everything fresh,
it works again. Is the problem with the macro or something else?

  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Gordon Bentley-Mix[_4_] Gordon Bentley-Mix[_4_] is offline
external usenet poster
 
Posts: 82
Default Macro doesn't work

Probably best asked in the VBA newsgroup, but since I'm here...

Two questions:
1. What does the error say?
2. What does the code that creates sFileName look like?
--
Cheers!

Gordon Bentley-Mix

"Kerry" wrote in message
...
I have a macro which saves my Word doc as a pdf based on words within the
document itself. Sometimes I get an error and the macro stops on the
following line:

ActiveDocument.ExportAsFixedFormat OutputFileName:=sFileName, _
ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False,
OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1,
To:=1, _
Item:=wdExportDocumentContent, IncludeDocProps:=False,
KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True,
_
BitmapMissingFonts:=True, UseISO19005_1:=False

sFileName is a string

If I close out of all my Office apps (Outlook, Word 2007) then reopen Word
and invoke the macro right away, it will work beautifully. I don't know
if
it has to do with the other apps or not, but if I restart everything
fresh,
it works again. Is the problem with the macro or something else?

  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Gordon Bentley-Mix[_4_] Gordon Bentley-Mix[_4_] is offline
external usenet poster
 
Posts: 82
Default Macro doesn't work


Probably best asked in the VBA newsgroup, but since I'm here...

Two questions:
1. What does the error say?
2. What does the code that creates sFileName look like?
--
Cheers!

Gordon Bentley-Mix

"Kerry" wrote in message
...
I have a macro which saves my Word doc as a pdf based on words within the
document itself. Sometimes I get an error and the macro stops on the
following line:

ActiveDocument.ExportAsFixedFormat OutputFileName:=sFileName, _
ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False,
OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1,
To:=1, _
Item:=wdExportDocumentContent, IncludeDocProps:=False,
KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True,
_
BitmapMissingFonts:=True, UseISO19005_1:=False

sFileName is a string

If I close out of all my Office apps (Outlook, Word 2007) then reopen Word
and invoke the macro right away, it will work beautifully. I don't know
if
it has to do with the other apps or not, but if I restart everything
fresh,
it works again. Is the problem with the macro or something else?

  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Kerry Kerry is offline
external usenet poster
 
Posts: 45
Default Macro doesn't work

Wouldn't you know, it's working right now and I don't know how to get it to
replicate the problem, so I don't know exactly what the error says.

The code that creates sFileName is:

sFileName = "C:\Users\Kerry.Atkinson\Documents\" & (year + "-" + base +
"-" + Rank + first + last) & ".pdf"

But like I said the whole macro works beautifully, and when it doesn't, all
I have to do is close out of the apps and it works again. I have noticed,
though, that if I just restart Word but not Outlook, then it still doesn't
work. I have to close out of both for it to work again. I don't know if it
makes a difference, but I'm on Vista.

thanks
"Gordon Bentley-Mix" wrote:

Probably best asked in the VBA newsgroup, but since I'm here...

Two questions:
1. What does the error say?
2. What does the code that creates sFileName look like?
--
Cheers!

Gordon Bentley-Mix

"Kerry" wrote in message
...
I have a macro which saves my Word doc as a pdf based on words within the
document itself. Sometimes I get an error and the macro stops on the
following line:

ActiveDocument.ExportAsFixedFormat OutputFileName:=sFileName, _
ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False,
OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1,
To:=1, _
Item:=wdExportDocumentContent, IncludeDocProps:=False,
KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True,
_
BitmapMissingFonts:=True, UseISO19005_1:=False

sFileName is a string

If I close out of all my Office apps (Outlook, Word 2007) then reopen Word
and invoke the macro right away, it will work beautifully. I don't know
if
it has to do with the other apps or not, but if I restart everything
fresh,
it works again. Is the problem with the macro or something else?

  #5   Report Post  
Posted to microsoft.public.word.docmanagement
Kerry Kerry is offline
external usenet poster
 
Posts: 45
Default Macro doesn't work


Wouldn't you know, it's working right now and I don't know how to get it to
replicate the problem, so I don't know exactly what the error says.

The code that creates sFileName is:

sFileName = "C:\Users\Kerry.Atkinson\Documents\" & (year + "-" + base +
"-" + Rank + first + last) & ".pdf"

But like I said the whole macro works beautifully, and when it doesn't, all
I have to do is close out of the apps and it works again. I have noticed,
though, that if I just restart Word but not Outlook, then it still doesn't
work. I have to close out of both for it to work again. I don't know if it
makes a difference, but I'm on Vista.

thanks
"Gordon Bentley-Mix" wrote:

Probably best asked in the VBA newsgroup, but since I'm here...

Two questions:
1. What does the error say?
2. What does the code that creates sFileName look like?
--
Cheers!

Gordon Bentley-Mix

"Kerry" wrote in message
...
I have a macro which saves my Word doc as a pdf based on words within the
document itself. Sometimes I get an error and the macro stops on the
following line:

ActiveDocument.ExportAsFixedFormat OutputFileName:=sFileName, _
ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False,
OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1,
To:=1, _
Item:=wdExportDocumentContent, IncludeDocProps:=False,
KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True,
_
BitmapMissingFonts:=True, UseISO19005_1:=False

sFileName is a string

If I close out of all my Office apps (Outlook, Word 2007) then reopen Word
and invoke the macro right away, it will work beautifully. I don't know
if
it has to do with the other apps or not, but if I restart everything
fresh,
it works again. Is the problem with the macro or something else?



  #6   Report Post  
Posted to microsoft.public.word.docmanagement
Gordon Bentley-Mix[_4_] Gordon Bentley-Mix[_4_] is offline
external usenet poster
 
Posts: 82
Default Macro doesn't work

Kerry,

If it does crash again, make a careful note of the error message and post
back. I'll watch this thread for any further developments. However, I can't
see anything glaringly wrong with the code - although it's not exactly clear
what "year", "base", etc. are and where they come from. (I'm assuming that
they're variables who's values are extracted from the content of the
document, yes?) It could be that one of these values goes missing under
certain circumstances, and this is causing sFile to be malformed somehow.
When the error does occur, if you hover over sFile in the VBA editor, it
should show you the current value. Something to investigate...

As for having to close Outlook as well as Word, when the code crashes it's
apparently doing so in a way that cause the VBA compiler to hang - possibly
because memory allocated for stuff associated with the code isn't being
released. If you are running Office 2003 or older and using Word as your
email editor in Outlook, then the "hung" instance of Word is still running
even after Word is closed. Consequently, you have to close Outlook before
Word will truly restart as a fresh instance.
--
Cheers!

Gordon Bentley-Mix

"Kerry" wrote in message
...
Wouldn't you know, it's working right now and I don't know how to get it
to
replicate the problem, so I don't know exactly what the error says.

The code that creates sFileName is:

sFileName = "C:\Users\Kerry.Atkinson\Documents\" & (year + "-" + base +
"-" + Rank + first + last) & ".pdf"

But like I said the whole macro works beautifully, and when it doesn't,
all
I have to do is close out of the apps and it works again. I have noticed,
though, that if I just restart Word but not Outlook, then it still doesn't
work. I have to close out of both for it to work again. I don't know if
it
makes a difference, but I'm on Vista.

thanks
"Gordon Bentley-Mix" wrote:

Probably best asked in the VBA newsgroup, but since I'm here...

Two questions:
1. What does the error say?
2. What does the code that creates sFileName look like?
--
Cheers!

Gordon Bentley-Mix

"Kerry" wrote in message
...
I have a macro which saves my Word doc as a pdf based on words within
the
document itself. Sometimes I get an error and the macro stops on the
following line:

ActiveDocument.ExportAsFixedFormat OutputFileName:=sFileName, _
ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False,
OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1,
To:=1, _
Item:=wdExportDocumentContent, IncludeDocProps:=False,
KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks,
DocStructureTags:=True,
_
BitmapMissingFonts:=True, UseISO19005_1:=False

sFileName is a string

If I close out of all my Office apps (Outlook, Word 2007) then reopen
Word
and invoke the macro right away, it will work beautifully. I don't
know
if
it has to do with the other apps or not, but if I restart everything
fresh,
it works again. Is the problem with the macro or something else?

  #7   Report Post  
Posted to microsoft.public.word.docmanagement
Gordon Bentley-Mix[_4_] Gordon Bentley-Mix[_4_] is offline
external usenet poster
 
Posts: 82
Default Macro doesn't work


Kerry,

If it does crash again, make a careful note of the error message and post
back. I'll watch this thread for any further developments. However, I can't
see anything glaringly wrong with the code - although it's not exactly clear
what "year", "base", etc. are and where they come from. (I'm assuming that
they're variables who's values are extracted from the content of the
document, yes?) It could be that one of these values goes missing under
certain circumstances, and this is causing sFile to be malformed somehow.
When the error does occur, if you hover over sFile in the VBA editor, it
should show you the current value. Something to investigate...

As for having to close Outlook as well as Word, when the code crashes it's
apparently doing so in a way that cause the VBA compiler to hang - possibly
because memory allocated for stuff associated with the code isn't being
released. If you are running Office 2003 or older and using Word as your
email editor in Outlook, then the "hung" instance of Word is still running
even after Word is closed. Consequently, you have to close Outlook before
Word will truly restart as a fresh instance.
--
Cheers!

Gordon Bentley-Mix

"Kerry" wrote in message
...
Wouldn't you know, it's working right now and I don't know how to get it
to
replicate the problem, so I don't know exactly what the error says.

The code that creates sFileName is:

sFileName = "C:\Users\Kerry.Atkinson\Documents\" & (year + "-" + base +
"-" + Rank + first + last) & ".pdf"

But like I said the whole macro works beautifully, and when it doesn't,
all
I have to do is close out of the apps and it works again. I have noticed,
though, that if I just restart Word but not Outlook, then it still doesn't
work. I have to close out of both for it to work again. I don't know if
it
makes a difference, but I'm on Vista.

thanks
"Gordon Bentley-Mix" wrote:

Probably best asked in the VBA newsgroup, but since I'm here...

Two questions:
1. What does the error say?
2. What does the code that creates sFileName look like?
--
Cheers!

Gordon Bentley-Mix

"Kerry" wrote in message
...
I have a macro which saves my Word doc as a pdf based on words within
the
document itself. Sometimes I get an error and the macro stops on the
following line:

ActiveDocument.ExportAsFixedFormat OutputFileName:=sFileName, _
ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False,
OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1,
To:=1, _
Item:=wdExportDocumentContent, IncludeDocProps:=False,
KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks,
DocStructureTags:=True,
_
BitmapMissingFonts:=True, UseISO19005_1:=False

sFileName is a string

If I close out of all my Office apps (Outlook, Word 2007) then reopen
Word
and invoke the macro right away, it will work beautifully. I don't
know
if
it has to do with the other apps or not, but if I restart everything
fresh,
it works again. Is the problem with the macro or something else?

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro does not work Purplejopeg Microsoft Word Help 1 April 2nd 08 12:32 PM
Macro won't work... silas[_2_] New Users 5 January 8th 08 07:26 PM
Getting a Macro to Work Right Joe McGuire Microsoft Word Help 4 January 31st 07 07:25 AM
Macro doesn't work Anna Microsoft Word Help 9 October 17th 05 10:25 PM
Macro that won't work Danker Schaareman Microsoft Word Help 1 September 30th 05 04:42 AM


All times are GMT +1. The time now is 04:07 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"