![]() |
#2
|
||||
|
||||
![]()
Whilst ChaGPT can write code that looks like valid VBA, the code very often either doesn't work at all, or doesn't do what is intended. Its use has been banned at StackOverflow, for example.
ChatGPT even acknowledges the pitfalls: Quote:
Code:
Sub SavePagesAsJPEG() ' Declare variables Dim PageCount As Integer Dim i As Integer Dim FileName As String ' Get the number of pages in the document PageCount = ActiveDocument.ComputeStatistics(wdStatisticPages) ' Loop through each page For i = 1 To PageCount ' Set the file name for the current page FileName = "Page" & i & ".jpg" ' Save the current page as a JPEG file ActiveDocument.ExportAsFixedFormat OutputFileName:=FileName, ExportFormat:=wdExportFormatJPEG, OpenAfterExport:=False, OptimizeFor:=wdExportOptimizeForPrint, Range:=wdExportFromTo, From:=i, To:=i Next i End Sub Please don't post ChatGPT-generated code here that you haven't debugged beforehand - either as an answer or to seek help correcting.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Need Help to write macros | Manivarthanan | Word VBA | 1 | 08-15-2018 10:56 AM |
How to write VBA in following example | yoyo4 | Excel Programming | 3 | 12-06-2017 12:30 AM |
How to write macro | yoyo4 | Excel Programming | 1 | 11-19-2017 11:43 PM |
write need help and copy write need help on another page auto | wykoems | Word | 2 | 07-25-2013 07:56 AM |
![]() |
dkub | Word VBA | 1 | 07-21-2012 09:01 PM |