muraterguen
New Member
- Joined
- Jan 8, 2016
- Messages
- 25
Hi,
I'm having a problem here which I searched in forums and I tried to fix it based on what I learned yet no success. I have actually asked this question to a thread, then figured that it was a solved case very old thread and wont get any attention for it. I need solution urgent so I might seek an answer in other forums as well such as ExcelGuru and ExcelForum( Cross post policy)
I wanted to create a macro selects some part of my worksheet and saves it in to the defined directory with the file name in A1.
A1 had the formula ( =TEXT(G2,"mmm/dd/yy")&" TO "&TEXT(P2,"mmm/dd/yy") ) as the file name display. I thought it was the problem so I moved the formula to A2, added Copy-Paste Values action to the macro (copy to A1 again) But still the same problem. It gives me an error saying Run time error 1004 File Not saved. When I click DEBUG, I see whole code block is colored yellow in VBA editor.
Here below is the code
I would appreciate if anyone could point out the mistake....
Sub PP()
'
' PP Macro
'
' Keyboard Shortcut: Ctrl+Shift+P
'
Range("A2").Select
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("A1:U86").Select
Selection.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\Murat Erguden\Dropbox\PLANET\5STAR CHA\PAYROLL\2017\ & Range("A1").Value ".pdf" _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
Application.WindowState = xlNormal
End Sub
I'm having a problem here which I searched in forums and I tried to fix it based on what I learned yet no success. I have actually asked this question to a thread, then figured that it was a solved case very old thread and wont get any attention for it. I need solution urgent so I might seek an answer in other forums as well such as ExcelGuru and ExcelForum( Cross post policy)
I wanted to create a macro selects some part of my worksheet and saves it in to the defined directory with the file name in A1.
A1 had the formula ( =TEXT(G2,"mmm/dd/yy")&" TO "&TEXT(P2,"mmm/dd/yy") ) as the file name display. I thought it was the problem so I moved the formula to A2, added Copy-Paste Values action to the macro (copy to A1 again) But still the same problem. It gives me an error saying Run time error 1004 File Not saved. When I click DEBUG, I see whole code block is colored yellow in VBA editor.
Here below is the code
I would appreciate if anyone could point out the mistake....
Sub PP()
'
' PP Macro
'
' Keyboard Shortcut: Ctrl+Shift+P
'
Range("A2").Select
Selection.Copy
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Range("A1:U86").Select
Selection.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\Murat Erguden\Dropbox\PLANET\5STAR CHA\PAYROLL\2017\ & Range("A1").Value ".pdf" _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
Application.WindowState = xlNormal
End Sub