Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
|
Lista Forumurilor Pe Tematici
|
Mrrrr's Forum (VIEW ONLY) | Reguli | Inregistrare | Login
POZE MRRRR'S FORUM (VIEW ONLY)
Nu sunteti logat.
|
Nou pe simpatie: sunrise2007 la Simpatie.ro
 | Femeie 21 ani Bucuresti cauta Barbat 34 - 54 ani |
|
TRaP
Moderator
Inregistrat: acum 6 ani
Postari: 795
|
|
Pressing a button linked to the following code will open an InputBox asking for the desired file name, then after pressing OK the file will be saved to desktop.
Source for getting special folder path using VBA: Rest was done with macro recorder.
Sub FileSaveToDesktop()
Dim FileName As String Dim objSFolders As Object Dim FilePath As String Set objSFolders = CreateObject("WScript.Shell").SpecialFolders
FilePath = objSFolders("desktop")
FileName = InputBox("Enter file name and press OK to save it to Desktop as xlsx file")
ActiveWorkbook.SaveAs FileName:= _ FilePath & "\" & FileName & ".xlsx", FileFormat:= _ xlOpenXMLWorkbook, CreateBackup:=False End Sub
|
|
|
pus acum 6 ani |
|
Mrrrr
AdMiN
 Inregistrat: acum 18 ani
Postari: 2247
|
|
Another option to get to the desktop would be by using:
Environ("USERPROFILE") & "\Desktop\" |
but this sometimes has issues with OneDrive desktop. I will save the file to the "old" / "normal" Desktop instead of using the OneDrive Desktop.
_______________________________________

|
|
pus acum 9 luni |
|
Mrrrr
AdMiN
 Inregistrat: acum 18 ani
Postari: 2247
|
|
This is the best method that I found so far that addresses the OneDrive desktop "issue" and saves in there:
savePath = CreateObject("WScript.Shell").SpecialFolders("Desktop") & Application.PathSeparator
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ savePath & ActiveSheet.Range("A2").Value & " - " & Format(Date, "dd.mm.yyyy") & ".pdf", _ Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False |
_______________________________________

|
|
pus acum 9 luni |
|
Mrrrr
AdMiN
 Inregistrat: acum 18 ani
Postari: 2247
|
|
More:
_______________________________________

|
|
pus acum 9 luni |
|
TRaP
Moderator
Inregistrat: acum 6 ani
Postari: 795
|
|
Code to save specific sheet if sheet name is something specific (can be updated to use sheet name only from specific file too) with certain data extracted from said sheet, and all other sheets from any other document with current time in file name.
Sub Save_As_PDF() Application.ScreenUpdating = False Application.PrintCommunication = False
Dim ws As Worksheet Set ws = ActiveSheet If ActiveSheet.Name = "SPECIFIC_SHEET_NAME" Then ActiveSheet.ExportAsFixedFormat 0, _ CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\" & _ ws.Range("C5").Value & "-" & _ ws.Range("I2").Value & "-" & _ "F.01.04.77" & "-" & _ ws.Range("C7").Value & "-" & _ Replace(ws.Range("C8").Value, "*", "X") & "-" & _ ws.Range("C6").Value & _ ".pdf", _ Quality:=xlQualityStandard, _ IncludeDocProperties:=True, _ IgnorePrintAreas:=False, _ From:=1, _ OpenAfterPublish:=False ' To:=1 ' ca sa listeze doar pagina 1 la 1; fara To, salveaza tot ce e vizibil Else ActiveSheet.ExportAsFixedFormat 0, _ CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\" & ActiveSheet.Name & " - " & Format(Now, "hh.mm.ss") & ".pdf", _ Quality:=xlQualityStandard, _ IncludeDocProperties:=True, _ IgnorePrintAreas:=False, _ From:=1, _ OpenAfterPublish:=False ' To:=1 ' ca sa listeze doar pagina 1 la 1; fara To, salveaza tot ce e vizibil
End If Application.PrintCommunication = True Application.ScreenUpdating = True End Sub |
|
|
pus acum 8 luni |
|
TRaP
Moderator
Inregistrat: acum 6 ani
Postari: 795
|
|
ChatGTP suggestion to not use VBA: add a button to QAT from All Commands: Publish PDF or XPS.
|
|
pus acum 8 luni |
|