Genius123
asked on
Outlook form vb script
Hello,
I have a script that generates a PDF. Everything works, except I don't want the PDF to open. There's a constant called openAfterExport but I keep getting errors when using it. Here's my code. Thanks.
Sub CommandButtonIntro_Click()
'On Error Resume Next
JobYear = cstr(Year(Item.UserPropert ies("JobIn itiatedDat e")))
Set objDoc = GetWordDocAll("\\TGPS13VM1 \drawing$\ Jobs\Task_ Templates\ Letter-Pro ject Introduction - 2"+CDNTemplate+".dot")
Call FillFieldsIntro(objDoc)
objDoc.Application.ActiveD ocument.At tachedTemp late = "Normal"'objDoc.Applicatio n.Options. PrintBackg round = True
objDoc.application.Windows (1).Window State = wdWindowStateMaximize
If MsgBox("Make your changes to the Word doc first, then click Yes to save.", _
vbQuestion + vbYesNo) = vbYes Then
objDoc.Application.ActiveD ocument.Sa veAs "\\TGPS13VM1\drawing$\Jobs -"+JobYear +"\"+Item. UserProper ties("JobN umber")+" "+Item.UserProperties("Job Name")+"\" +Item.User Properties ("JobNumbe r")+" Intro"
End If
objDoc.ExportAsFixedFormat "\\TGPS13VM1\drawing$\Jobs -"+JobYear +"\"+Item. UserProper ties("JobN umber")+" "+Item.UserProperties("Job Name")+"\" +Item.User Properties ("JobNumbe r")+" Intro.pdf",wdExportFormatP DF,true,wd ExportOpti mizeForPri nt,wdExpor tAllDocume nt,OpenAft erExport
'Call RestoreWordIntro
objDoc.Close wdDoNotSaveChanges
'objWord.Quit
Set objDoc = Nothing
Set objWord = Nothing
Call CommandButtonIntroCover
End Sub
I have a script that generates a PDF. Everything works, except I don't want the PDF to open. There's a constant called openAfterExport but I keep getting errors when using it. Here's my code. Thanks.
Sub CommandButtonIntro_Click()
'On Error Resume Next
JobYear = cstr(Year(Item.UserPropert
Set objDoc = GetWordDocAll("\\TGPS13VM1
Call FillFieldsIntro(objDoc)
objDoc.Application.ActiveD
objDoc.application.Windows
If MsgBox("Make your changes to the Word doc first, then click Yes to save.", _
vbQuestion + vbYesNo) = vbYes Then
objDoc.Application.ActiveD
End If
objDoc.ExportAsFixedFormat
'Call RestoreWordIntro
objDoc.Close wdDoNotSaveChanges
'objWord.Quit
Set objDoc = Nothing
Set objWord = Nothing
Call CommandButtonIntroCover
End Sub
ASKER
No it's not. I will get an error saying undefined variable. I have other constants defined, but I don't know how to define that one. The other constants look like this:
Const wdExportAllDocument = 0
Const wdExportOptimizeForPrint = 0
Const wdExportDocumentContent = 0
Const wdExportFormatPDF = 17
Const wdExportCreateHeadingBookm arks = 1
I've tried this but it doesn't work:
const openAfterExport = false
Const wdExportAllDocument = 0
Const wdExportOptimizeForPrint = 0
Const wdExportDocumentContent = 0
Const wdExportFormatPDF = 17
Const wdExportCreateHeadingBookm
I've tried this but it doesn't work:
const openAfterExport = false
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ah ha! It worked! I understand how it works now too. It was a little bit of mystery before this. Thanks for your help. :-)
glad to be of help
Open in new window