Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-29-2018, 10:20 AM
mfiltvedt84 mfiltvedt84 is offline Remove visible command button when attaching in outlook Windows 10 Remove visible command button when attaching in outlook Office 2016
Novice
Remove visible command button when attaching in outlook
 
Join Date: Sep 2018
Posts: 6
mfiltvedt84 is on a distinguished road
Default Remove visible command button when attaching in outlook

See this code.
This works but Im trying to make the command button im pushing in the sheet, not visible when the sheet has been converted to pdf and attached in outlook. How do I remove the visible command button in the pdf..???

Private Sub CommandButton1_Click()
' Create PDF of active sheet and send as attachment.
'
Dim strPath As String, strFName As String
Dim OutApp As Object, OutMail As Object

'Create PDF of active sheet only
strPath = Environ$("temp") & "\" 'Or any other path, but include trailing "\"

strFName = ActiveWorkbook.Name
strFName = Left(strFName, InStrRev(strFName, ".") - 1) & "_" & ActiveSheet.Range("D7") & ".pdf"

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
strPath & strFName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False

'Set up outlook
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

'Create message
On Error Resume Next
With OutMail
.to = Range("L13") 'Insert required address here ########
.CC = ""
.BCC = ""
.Subject = "Interiør solskjerming Tilbud"
.Body = ""
.Attachments.Add strPath & strFName
.Display 'Use only during debugging ##############################


'.Send 'Uncomment to send e-mail ##############################
End With

'Delete any temp files created
Kill strPath & strFName
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Reply With Quote
  #2  
Old 09-29-2018, 11:07 PM
trevorc trevorc is offline Remove visible command button when attaching in outlook Windows 7 32bit Remove visible command button when attaching in outlook Office 2013
Competent Performer
 
Join Date: Jan 2017
Posts: 174
trevorc will become famous soon enoughtrevorc will become famous soon enough
Default

This ones easy,
Right click the command button and select properties, there should be an option to print/not print the command button, untick it and there you go.
Reply With Quote
  #3  
Old 09-30-2018, 09:16 AM
mfiltvedt84 mfiltvedt84 is offline Remove visible command button when attaching in outlook Windows 10 Remove visible command button when attaching in outlook Office 2016
Novice
Remove visible command button when attaching in outlook
 
Join Date: Sep 2018
Posts: 6
mfiltvedt84 is on a distinguished road
Default

Thanks, the button is gone when the attachment is in outlook, but the button goes away also in the template sheet im working in.... how not to remove the button there too?? I wanna continue work in the sheet..
Reply With Quote
  #4  
Old 09-30-2018, 12:59 PM
trevorc trevorc is offline Remove visible command button when attaching in outlook Windows 7 32bit Remove visible command button when attaching in outlook Office 2013
Competent Performer
 
Join Date: Jan 2017
Posts: 174
trevorc will become famous soon enoughtrevorc will become famous soon enough
Default

Quote:
Originally Posted by mfiltvedt84 View Post
Thanks, the button is gone when the attachment is in outlook, but the button goes away also in the template sheet im working in.... how not to remove the button there too?? I wanna continue work in the sheet..
The only thing that it should have done is stop the button being shown in a print preview, please provide a sample, and I'll have go at helping you again.
regards
Trevor
Reply With Quote
  #5  
Old 10-01-2018, 05:27 AM
mfiltvedt84 mfiltvedt84 is offline Remove visible command button when attaching in outlook Windows 10 Remove visible command button when attaching in outlook Office 2016
Novice
Remove visible command button when attaching in outlook
 
Join Date: Sep 2018
Posts: 6
mfiltvedt84 is on a distinguished road
Default

I have a original template file where im typing in data for send offers on products to customers. I have made a button on this template that runs this code under here.
The code makes av saveascopy file on a path on onedrive, but also opens outlook and attachd this excel file in converted pdf. But the button is shown in the pdf that has been converted and on the excel copy file that has been placed on onedrive. I want to keep the button on the template because im gonna send more offers to other customers. See?
But the button wont go away on the pdf or the copied sheet on onedrive.
-----------------------------

Private Sub CommandButton1_Click()
' Create PDF of active sheet and send as attachment.
'
Dim strPath As String, strFName As String
Dim OutApp As Object, OutMail As Object


'Create PDF of active sheet only
strPath = Environ$("temp") & "\" 'Or any other path, but include trailing "\"

strFName = ActiveWorkbook.Name
strFName = Left(strFName, InStrRev(strFName, ".") - 1) & "_" & ActiveSheet.Range("D7") & ".pdf"
ActiveWorkbook.SaveCopyAs Filename:="C:\Users\Marius Filtvedt\OneDrive - Omega Industrier AS\1. OMEGA\Omega Østfold\Tilbud kunder\Tilbud Interiør" & "_" & ActiveSheet.Range("D7") & ".xls"

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
strPath & strFName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False

'Set up outlook
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

'Create message
On Error Resume Next
ActiveSheet.Shapes("CommandButton1").Delete

With OutMail
.to = Range("L13") 'Insert required address here ########
.CC = ""
.BCC = ""
.Subject = "Interiør solskjerming Tilbud"
.Body = ""
.Attachments.Add strPath & strFName
.Display 'Use only during debugging ##############################
'.Send 'Uncomment to send e-mail ##############################
End With

'Delete any temp files created
Kill strPath & strFName
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Reply With Quote
  #6  
Old 10-01-2018, 06:17 AM
mfiltvedt84 mfiltvedt84 is offline Remove visible command button when attaching in outlook Windows 10 Remove visible command button when attaching in outlook Office 2016
Novice
Remove visible command button when attaching in outlook
 
Join Date: Sep 2018
Posts: 6
mfiltvedt84 is on a distinguished road
Default

Or doing it another way, how to remove the macroes when the fil in savecopyas has been done?? The file size in savecopyas is almost 3 timers larger with macro...
Reply With Quote
  #7  
Old 10-01-2018, 06:26 AM
trevorc trevorc is offline Remove visible command button when attaching in outlook Windows 7 32bit Remove visible command button when attaching in outlook Office 2013
Competent Performer
 
Join Date: Jan 2017
Posts: 174
trevorc will become famous soon enoughtrevorc will become famous soon enough
Default

Quote:
Originally Posted by mfiltvedt84 View Post
Or doing it another way, how to remove the macroes when the fil in savecopyas has been done?? The file size in savecopyas is almost 3 timers larger with macro...
Try setting the visible property of the button to false, before creating the pdf then set it to true after that is done.
Reply With Quote
  #8  
Old 10-01-2018, 12:51 PM
trevorc trevorc is offline Remove visible command button when attaching in outlook Windows 7 32bit Remove visible command button when attaching in outlook Office 2013
Competent Performer
 
Join Date: Jan 2017
Posts: 174
trevorc will become famous soon enoughtrevorc will become famous soon enough
Default

I should have added that you can use the recorder when you create the command button, to see the VBA code to use for turning the visible property on/off in your code.
Reply With Quote
  #9  
Old 10-02-2018, 02:34 AM
mfiltvedt84 mfiltvedt84 is offline Remove visible command button when attaching in outlook Windows 10 Remove visible command button when attaching in outlook Office 2016
Novice
Remove visible command button when attaching in outlook
 
Join Date: Sep 2018
Posts: 6
mfiltvedt84 is on a distinguished road
Default

Quote:
Originally Posted by trevorc View Post
I should have added that you can use the recorder when you create the command button, to see the VBA code to use for turning the visible property on/off in your code.
Ok.

Another problem.
When om saving my file with savecopyas the Template im saving can sometimes be to the same customer but different offer. How will my code look like to add a -1 or something on filename when saving...? Where to put it? When everytime I write offer to the same customer it shallautomatically add 1, then 2 and so on.. help
Reply With Quote
  #10  
Old 10-02-2018, 12:35 PM
trevorc trevorc is offline Remove visible command button when attaching in outlook Windows 7 32bit Remove visible command button when attaching in outlook Office 2013
Competent Performer
 
Join Date: Jan 2017
Posts: 174
trevorc will become famous soon enoughtrevorc will become famous soon enough
Default

Quote:
Originally Posted by mfiltvedt84 View Post
Ok.

Another problem.
When om saving my file with savecopyas the Template im saving can sometimes be to the same customer but different offer. How will my code look like to add a -1 or something on filename when saving...? Where to put it? When everytime I write offer to the same customer it shallautomatically add 1, then 2 and so on.. help
You already have your answer above, this is what you do for that as well. Keep a record on your sheet of the last used number and add this to the file name as you have done for whatever you have in D7... & ActiveSheet.Range("D7") &
Reply With Quote
  #11  
Old 10-02-2018, 02:47 PM
mfiltvedt84 mfiltvedt84 is offline Remove visible command button when attaching in outlook Windows 10 Remove visible command button when attaching in outlook Office 2016
Novice
Remove visible command button when attaching in outlook
 
Join Date: Sep 2018
Posts: 6
mfiltvedt84 is on a distinguished road
Default

Quote:
Originally Posted by trevorc View Post
You already have your answer above, this is what you do for that as well. Keep a record on your sheet of the last used number and add this to the file name as you have done for whatever you have in D7... & ActiveSheet.Range("D7") &
But how does I do it? How will the code look like?
Reply With Quote
  #12  
Old 10-02-2018, 04:33 PM
trevorc trevorc is offline Remove visible command button when attaching in outlook Windows 7 32bit Remove visible command button when attaching in outlook Office 2013
Competent Performer
 
Join Date: Jan 2017
Posts: 174
trevorc will become famous soon enoughtrevorc will become famous soon enough
Default

ActiveWorkbook.SaveCopyAs Filename:="C:\Users\Marius Filtvedt\OneDrive - Omega Industrier AS\1. OMEGA\Omega Østfold\Tilbud kunder\Tilbud Interiør" & "_" & ActiveSheet.Range("D7") & ActiveSheet.Range("XX1") & ".xls"

XX1 or whatever holds your file number
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Show table list by using chek box command and save document on sharepoint by using command button Zhibek Word VBA 3 08-16-2018 06:19 PM
can't remove page break that isn't visible in nonprinted characters georgiajmj49 Word 8 07-19-2018 03:27 AM
Outlook 'Start Page' Command Button Wobble Outlook 0 03-31-2015 04:49 AM
Help with a Command Button dkohnken Word VBA 5 03-18-2015 10:13 PM
Command Button knp11 PowerPoint 2 01-18-2015 01:41 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:43 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft