mkwadvisory
New Member
- Joined
- Mar 1, 2021
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
Hi,
I run into an issue with the macro that I tried to use.
I want to save only the tabs that are named as numbers as PDF.
The code that I used isn't working fully as its does save tab named "1" and "2" as pdf but when I try to open the pdf file the adobe informs me that the file is corrupted.
I will appreciate if you could help. I also tried to assign this code to button but I can't select it.
Also is it possible to add to the code that it would save file as text contained in the cell A1 in each tab?
I run into an issue with the macro that I tried to use.
I want to save only the tabs that are named as numbers as PDF.
The code that I used isn't working fully as its does save tab named "1" and "2" as pdf but when I try to open the pdf file the adobe informs me that the file is corrupted.
I will appreciate if you could help. I also tried to assign this code to button but I can't select it.
Also is it possible to add to the code that it would save file as text contained in the cell A1 in each tab?
VBA Code:
Private Sub Filesaveas()
Dim a As Integer
Dim ws As Worksheet
Dim wb As Workbook
a = ThisWorkbook.Sheets.Count
For i = 1 To a
If ThisWorkbook.Worksheets(i).Name <> "Sheet1" And ThisWorkbook.Worksheets(i).Name <> "tab1" Then
Set wb = Workbooks.Add
ThisWorkbook.Worksheets(i).Copy before:=wb.Worksheets(1)
wb.SaveAs "C:\Users\User\OneDrive\Pictures" & "\" & ActiveSheet.Name & ".pdf"
wb.Close savechanges = True
End If
Next i
MsgBox ("ok")