|22 Oct 2016||#1|
office 2007 macro help
I am trying insert picture in active document and then either mail it as pdf or print directly to printer.
I have written following code which works ok if I step through it in code window. but on executing directly from document direct print option doesn't send the document to printer quene though printer does get activated in task bar but shows 0 document to print.
Can somebody guide me ?
code is as follows
Dim filename As String
.Text = "xxxxxxxx"
.Forward = True
.Wrap = wdFindContinue
.MatchWildcards = True
.AddPicture filename:="C:\xx.png", LinkToFile:=False, _
Dim YesOrNoAnswerToMessageBox As String
Dim QuestionToMessageBox As String
Dim mailaddress As String
QuestionToMessageBox = "want to send mail?"
YesOrNoAnswerToMessageBox = MsgBox(QuestionToMessageBox, vbYesNo, "VBA Expert or Not")
If YesOrNoAnswerToMessageBox = vbNo Then
If YesOrNoAnswerToMessageBox = vbYes Then
filename = InputBox("yyyy")
Dim FName As String
FName = "d:\zzzz\" & filename & ".pdf"
ActiveDocument.SaveAs ("D:\zzzz\") & filename
myfile1 = ActiveDocument.Name
intPos = InStrRev(myfile1, ".")
If intPos > 0 Then
myfile = Left(myfile1, intPos - 1)
ActiveDocument.ExportAsFixedFormat OutputFileName:= _
Replace(ActiveDocument.FullName, ".docx", ".pdf"), _
ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, Item:= _
wdExportDocumentContent, IncludeDocProps:=False, KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
mailaddress = InputBox("")
FName = "d:\zzzz\" & myfile & ".pdf"
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
On Error Resume Next
If Len(ActiveDocument.Path) = 0 Then
MsgBox "Document needs to be saved first"
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
Set oItem = oOutlookApp.CreateItem(olMailItem)
.To = mailaddress
.Subject = myfile
|My System Specs|
|Thread Tools||Search this Thread|
|Similar help and support threads|
MS Office 2010 - Word Macro
I am a novice at this and I have searched and searched over the last week trying to figure out a fix to this. I'm trying to create a Word Macro to remove time from date: This occurs in 4 different cells. Cell in Word shows: 05/04/2016 10:00:00 I just need the date to show without the...
When I open a Word 2007 document, a Visual Basic editing macro opens
When I open any existing (not when I create a new) Word 2007 document (in this case one entitled “Word 2007 test document”), I am greeted with the following: attached image VB01 When I click on I get: attached image VB02
Excel 2007 (MS Office 2007 enterprise)
I recently formatted my HD and reinstalled MS Office Enterprise 2007, I last used MS Excel on the 08/06/2014 without a problem, today I go to use my Excel spreadsheet and for some weird reason it wants to roundup my cells. I have cleared the cells formatted the number but it still keeps on...
Office 2010(Win7, 64bit) won't open Office 2007(WinXPr3 32 bit) files
Just bought a new laptop with Windows7 64bit installed-my first exposure to Windows7. I had Office 2007 installed on my old Dell 32 bit machine. I had also recently pruchased Office 2010 and installed that on my new machine. Now, when I try to open those 32bit 2007 files with 64bt 2011, Iget...
File Validation from Office 2010 to Office 2003 and Office 2007
File Validation from Office 2010 to Office 2003 and Office 2007 - Softpedia
Word 2007 Macro Alert Since Win7 upgrade
Word 2007 displays several Macro warnings when I open a simple Word document that contains no macros what so ever. The .Doc is just a table of four columns with data. This same .DOC opened without any problem while running Vista64. All I did was an upgrade. Word was installed during Vista64...
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd
All times are GMT -5. The time now is 21:41.