Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 88
Default need help to update macro to office 2007 macro enabled workbook

good morning,

i compiled this macro for office 2003 with help from users here, and now i'm
back again because we have upgraded to office 2007. i have also changed the
file to office 2007 - macro enabled.

the following macro, sends a copy of the excel sheet, then saves a copy in
pdf format (using the MS add-in) and goes through a few other things as you
will see. i need two things in this macro, and i have those items [IN THIS
FORMAT - ALL CAPS]


Sub POInv()
' Macro recorded 8/28/2006 by Jat
'
If ActiveSheet.Name = "Purchase Order (Inventory)" Then
'Sub SaveName() - multiple steps
ActiveSheet.Copy 'creates a new one page workbook with a copy of
the activesheet in it, this becomes the activesheet/book
ActiveSheet.Name = Range("L5").Value 'renames the active sheet
(from ActiveSheet.Copy) to the purchase order value located in cell M5 [I
WOULD LIKE THE SHEET NAME TO INCLUDE THE SUPPLIER NAME IN CELL D11. I have
tried adding the cell d11 into the activesheet.name range but i cannot figure
it out.]
Range("L7") = Now
strdate = Format(Now, "mm-dd-yy h-mm-ss")
ActiveSheet.Protect
'End Sub

'Sub Email() - sends a copy of the email to the recipients in an excel
format(should be accounts payable department, or similar)
ActiveWorkbook.SendMail ",
Subject:=ActiveSheet.Name

[IN THE EMAIL, THE EXCEL ATTACHMENT'S NAME IS BOOK1.XLSX. I WOULD LIKE THE
ATTACHMENT'S NAME TO BE THE SAME AS THE ACTIVESHEET.NAME. I tried
Attachment:=ActiveSheet.Name but not that easy.]

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\Jat\Desktop\Operations\Purchase Orders\Purchase Orders
Issued\" & ActiveSheet.Name & ".pdf" _
, Quality:=xlQualityStandard, IncludeDocProperties:=True,
IgnorePrintAreas _
:=False, OpenAfterPublish:=False

ActiveWorkbook.Close SaveChanges:=False 'don't ask - kind of looks
good.
'End Sub Email()

'Sub Count() 'increases the PO number (stored in cell K8 and
displayed in M5)
mycount = Range("K8") + 1
Range("K8") = mycount
'End Sub

'Sub ClearContents() - Clears the contents in selectable cells, and
reverts the actual PO to it's original form

Range("L9,L11,L13,L15,D11:G15,A18:K38,E39,G39,J39, C41,E41,H41,B43:K46,L50,A51:G51,F5:H8").Select
Selection.ClearContents
Range("B18:I18").Select
Range("B18:I18").Select
Selection.Copy

Range("B38:I38").Select
ActiveSheet.Paste
Application.ScreenUpdating = True
Range("D11:G11").Select
'End Sub

'Sub AutoSave() - saves the updated purchase order
ActiveWorkbook.Save
'End Sub

End If

End Sub


well, that's it. just two simple things to keep the macro simple. any help
would be appreciated.

thank you,

jat jaswal

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default need help to update macro to office 2007 macro enabled workbook

To change the worksheet name try this
from
ActiveSheet.Name = Range("L5").Value
to
ActiveSheet.Name = Range("L5").Value & Range("D11").Value


Because you created a new workbook and haven't saved the wrokbook the name
defaults to BOOK1.XLSX. You need to "save as" the file to change the name
before you e-mail the file. the "save as" need to ber before the line which
writes the subject line in the e-mail.

ActiveWorkbook.SendMail ",
Subject:=ActiveSheet.Name


"jatman" wrote:

good morning,

i compiled this macro for office 2003 with help from users here, and now i'm
back again because we have upgraded to office 2007. i have also changed the
file to office 2007 - macro enabled.

the following macro, sends a copy of the excel sheet, then saves a copy in
pdf format (using the MS add-in) and goes through a few other things as you
will see. i need two things in this macro, and i have those items [IN THIS
FORMAT - ALL CAPS]


Sub POInv()
' Macro recorded 8/28/2006 by Jat
'
If ActiveSheet.Name = "Purchase Order (Inventory)" Then
'Sub SaveName() - multiple steps
ActiveSheet.Copy 'creates a new one page workbook with a copy of
the activesheet in it, this becomes the activesheet/book
ActiveSheet.Name = Range("L5").Value 'renames the active sheet
(from ActiveSheet.Copy) to the purchase order value located in cell M5 [I
WOULD LIKE THE SHEET NAME TO INCLUDE THE SUPPLIER NAME IN CELL D11. I have
tried adding the cell d11 into the activesheet.name range but i cannot figure
it out.]
Range("L7") = Now
strdate = Format(Now, "mm-dd-yy h-mm-ss")
ActiveSheet.Protect
'End Sub

'Sub Email() - sends a copy of the email to the recipients in an excel
format(should be accounts payable department, or similar)
ActiveWorkbook.SendMail ",
Subject:=ActiveSheet.Name

[IN THE EMAIL, THE EXCEL ATTACHMENT'S NAME IS BOOK1.XLSX. I WOULD LIKE THE
ATTACHMENT'S NAME TO BE THE SAME AS THE ACTIVESHEET.NAME. I tried
Attachment:=ActiveSheet.Name but not that easy.]

ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\Jat\Desktop\Operations\Purchase Orders\Purchase Orders
Issued\" & ActiveSheet.Name & ".pdf" _
, Quality:=xlQualityStandard, IncludeDocProperties:=True,
IgnorePrintAreas _
:=False, OpenAfterPublish:=False

ActiveWorkbook.Close SaveChanges:=False 'don't ask - kind of looks
good.
'End Sub Email()

'Sub Count() 'increases the PO number (stored in cell K8 and
displayed in M5)
mycount = Range("K8") + 1
Range("K8") = mycount
'End Sub

'Sub ClearContents() - Clears the contents in selectable cells, and
reverts the actual PO to it's original form

Range("L9,L11,L13,L15,D11:G15,A18:K38,E39,G39,J39, C41,E41,H41,B43:K46,L50,A51:G51,F5:H8").Select
Selection.ClearContents
Range("B18:I18").Select
Range("B18:I18").Select
Selection.Copy

Range("B38:I38").Select
ActiveSheet.Paste
Application.ScreenUpdating = True
Range("D11:G11").Select
'End Sub

'Sub AutoSave() - saves the updated purchase order
ActiveWorkbook.Save
'End Sub

End If

End Sub


well, that's it. just two simple things to keep the macro simple. any help
would be appreciated.

thank you,

jat jaswal

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why doesn't Excel 2007 record charting and office art macro code? NOLuckMatt Excel Discussion (Misc queries) 0 August 17th 07 02:38 PM
Unable to run macro in Office 2007 Mahesh Excel Discussion (Misc queries) 1 August 1st 07 11:14 PM
Macro need to update the workbook x6v87qe Excel Discussion (Misc queries) 6 May 3rd 07 04:42 AM
Default a workbook to save as a xlsm (macro-enabled) in 2007 Razzer204 Excel Discussion (Misc queries) 3 March 21st 07 06:10 PM
Where in Office 2007 can I record a macro? Graeme Excel Worksheet Functions 1 August 15th 06 03:07 PM


All times are GMT +1. The time now is 11:59 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"