Print or Save Excel UserForm as PDF file during run time using VBA

  Рет қаралды 4,612

Ah Sing Excel TV

Ah Sing Excel TV

Күн бұрын

Пікірлер: 32
@ahsing_excel_VBA
@ahsing_excel_VBA 4 ай бұрын
Known issues: 1. Error where variable is not defined. Suggestion: Delete the newly created blank sheet, save your workbook, close and reopen it. Then, run the code again. If the error persists, add 'ws.Select' before 'ws.Paste' and check the second point. 2. PDF file gets corrupted when opened. Suggestion: Add the parameter 'ActivePrinter:="Microsoft Print to PDF"' before 'PrToFileName' so that Excel will convert the file to PDF for you. Hope you find this information useful. Thanks for watching and have a wonderful day!
@Elizabeth-qp3uj
@Elizabeth-qp3uj Ай бұрын
Thanks for this quick & easy manner macro. If you could help me with a current issue: Sometimes, not always, the screenshot is not of the Userform, but rather something else on the PC screen. This happens only to the users running Windows 11, not an issue with those of us using Windows 10. I added a loop of 10 'DoEvents' and now the occurrence happens less often, but I really need it to not ever grab the wrong screenshot. Is there anything else to do to ensure the focus is on the Userform? Thank you!
@ahsing_excel_VBA
@ahsing_excel_VBA Ай бұрын
My pleasure. Regarding your issue, I'm not sure if you can try the 'SetFocus' method. Setting focus on any control on the UserForm may help the macro better detect the desired window. I hope this helps. Thanks for watching, and I wish you a wonderful day!
@Elizabeth-qp3uj
@Elizabeth-qp3uj Ай бұрын
@@ahsing_excel_VBA Thank you, that's an easy fix and great idea. Thank you for your help. May your day be wonderful too.
@Elizabeth-qp3uj
@Elizabeth-qp3uj Ай бұрын
Shame, I had to drop this macro from my process since I couldn't get it to consistently screenshot the worksheet. I thought SetFocus would work, but it didn't. I added in loops of DoEvents and still had issues. My users were unhappy and I was frustrated putting out fires. Worked well on my Windows 10 PC, but inconsistent on Windows 11.
@mazenzagha8811
@mazenzagha8811 11 ай бұрын
Thanks again and again sir sir you are gentle 😊😊😊😊😊😊❤❤❤❤❤
@ahsing_excel_VBA
@ahsing_excel_VBA 11 ай бұрын
My pleasure 😉 Glad you like it. Thanks for watching and have a nice day.
@mazenzagha8811
@mazenzagha8811 11 ай бұрын
sir i have a massage when i run the program " the massage is acrobat reader could not open the file ,because either note supported type or beacause the file damaged ( it was sent as e-mailattached ,and was not correctly decoded " pls sir how solve this matter @@ahsing_excel_VBA
@ahsing_excel_VBA
@ahsing_excel_VBA 11 ай бұрын
Hi. May I know if the problem arises during runtime or when you open the file? It seems like the file format is incorrect.
@mazenzagha8811
@mazenzagha8811 11 ай бұрын
@@ahsing_excel_VBA sir thank you for replying me . Sir could you please send your email to send you the file to check it.seince i try many times and couldn't.pls sir
@mazenzagha8811
@mazenzagha8811 11 ай бұрын
@@ahsing_excel_VBA sir when i open the file pdf
@phole7591
@phole7591 8 ай бұрын
I following your coding but when I click on the newly created PDF, got an error "Not supported file type or damage .. not decode correctly". Can you help and give some pointers ? Thanks
@ahsing_excel_VBA
@ahsing_excel_VBA 8 ай бұрын
Hi. Your situation resembles Mazen's. It's likely due to the PDF opener. My suggestions were: 1. Ignore the very first error and rerun the macro again. 2. Try attempt to open the file using Microsoft Edge. 3. Alternatively, you might want to consider his solution, which involved converting the sheet to a PNG file instead of PDF. You can find more details in this video: kzbin.info/www/bejne/b6LXnWp3gZ6Sfa8. Additionally, if you'd like me to gain a better understanding of your issue, consider recording your screen from start to finish and sending it to me via Gmail or Facebook private message. Hope one of them help. Thanks for watching and have a nice day.
@nachiketbhale6150
@nachiketbhale6150 4 ай бұрын
i copied as it is VBA code but when i run the same , getting error as Variable not defined
@ahsing_excel_VBA
@ahsing_excel_VBA 4 ай бұрын
Hi, you can add a line to define the variable first.
@nachiketbhale6150
@nachiketbhale6150 4 ай бұрын
I tried to add as Dim WS as Worksheet Is it correct?
@nachiketbhale6150
@nachiketbhale6150 4 ай бұрын
@@ahsing_excel_VBA What line i need to add as variable, Can you provide me the line , It will help me
@ahsing_excel_VBA
@ahsing_excel_VBA 4 ай бұрын
yup. It is correct.
@nachiketbhale6150
@nachiketbhale6150 4 ай бұрын
i am getting error WS variable not defined - any one can help me
@ahsing_excel_VBA
@ahsing_excel_VBA 4 ай бұрын
Did you notice a new worksheet was added? If so, delete the new worksheet and run it again. It should be fine then.
@nachiketbhale6150
@nachiketbhale6150 4 ай бұрын
Yes every time new worksheet is getting created as blank
They Chose Kindness Over Abuse in Their Team #shorts
00:20
I migliori trucchetti di Fabiosa
Рет қаралды 11 МЛН
Wait for it 😂
00:19
ILYA BORZOV
Рет қаралды 11 МЛН
Trapped by the Machine, Saved by Kind Strangers! #shorts
00:21
Fabiosa Best Lifehacks
Рет қаралды 35 МЛН
Excel VBA Save Range to PDF
11:26
The Excel Cave
Рет қаралды 22 М.
Open PDF File In Userform Excell VBA
7:43
razakmcr
Рет қаралды 41 М.
Save Excel UserForm as picture during run time using VBA
8:09
Ah Sing Excel TV
Рет қаралды 745
How to Run UserForm without Showing Excel Window
12:44
TheDataLabs
Рет қаралды 116 М.
Page Setup and Printing from VBA - 1 of 3
19:45
Siddharth Rout
Рет қаралды 4,5 М.
They Chose Kindness Over Abuse in Their Team #shorts
00:20
I migliori trucchetti di Fabiosa
Рет қаралды 11 МЛН