View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
medic medic is offline
external usenet poster
 
Posts: 10
Default how do i create a macro that will print and save my file to sh

here is what i have -- getting a syntex error:
Sub saveandprint()
'
' saveandprint Macro
'

'
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _

"http://companyweb/General%20Documents/Insurance%20stuff/Patient%20OON%20bills/& Range("A1").Value _

, Quality:=xlQualityMinimum, IncludeDocProperties:=True,
IgnorePrintAreas _
:=False, From:=1, To:=1, OpenAfterPublish:=False
ExecuteExcel4Macro "PRINT(2,1,1,1,,,,,,,,2,,,TRUE,,FALSE)"
End Sub



"JP" wrote:

If the information was in A1 you could add it to the filename argument
like this:

Filename:= "http://companyweb/General%20Documents/Insurance%20stuff/
Patient%20OON..." & Range("A1").Value _
, Quality:=xlQualityStandard, IncludeDocProperties:=True,
IgnorePrintAreas:=False, OpenAfterPublish:=False


HTH,
JP

On Jan 7, 5:17 pm, medic wrote:
here is what i have now --how do i tell it to name the file based on date
created the pt name and their date of birth? I combined all the data into a
name in one cell using "&" but how do i tell the macro to pull the the data
from that cell (the result not the formula)?

Sub saveandprint()
'
' saveandprint Macro
'

'
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _

"http://companyweb/General%20Documents/Insurance%20stuff/Patient%20OON..." _
, Quality:=xlQualityStandard, IncludeDocProperties:=True,
IgnorePrintAreas _
:=False, OpenAfterPublish:=False
Application.ActivePrinter = "Xerox Phaser 6180MFP-D PCL 6 on Ne00:"
ExecuteExcel4Macro _
"PRINT(1,,,1,,,,,,,,2,""Xerox Phaser 6180MFP-D PCL 6 on
Ne00:"",,TRUE,,FALSE)"
End Sub



"JP" wrote:
I don't understand your code here.


1. By "x = d1.Value" do you mean "x = Range("D1").Value" ??


2. The FileName property only takes one argument, it looks like you
are trying to use two (variable 'x' and a workbook name). You can use


ActiveWorkbook.SaveAs Filename:=x


OR


ActiveWorkbook.SaveAs Filename:="C:\Users\medic\Documents\vaccine form
\vaccines form1.xlsm"


but not both at the same time.


HTH,
JP


On Jan 5, 10:02 am, medic wrote:
still wont work here is what I got the last 2 line are in red:


Sub save()
'
' save Macro
'


'
ChDir "C:\Users\medic\Documents\vaccine form"
x = d1.Value
ActiveWorkbook.SaveAs Filename:=x
"C:\Users\medic\Documents\vaccine form\vaccines form1.xlsm",
FileFormat:= _
xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
End Sub


thansk for the help


"JP" wrote:
Do you mean you want to use some cell entry as the filename?


X = Range("A1").Value
ActiveWorkbook.SaveAs Filename:=X


HTH,
JP- Hide quoted text -


- Show quoted text -