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:
ChatGPT sometimes writes plausible-sounding but incorrect or nonsensical answers. Fixing this issue is challenging, as: (1) during RL training, there’s currently no source of truth; (2) training the model to be more cautious causes it to decline questions that it can answer correctly; and (3) supervised training misleads the model because the ideal answer depends on what the model knows, rather than what the human demonstrator knows.
ChatGPT: Optimizing Language Models for Dialogue
|
As an example of bogus code produced by ChapGPT, consider:
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
The code looks OK, but there is no such thing as wdExportFormatJPEG...
Please don't post ChatGPT-generated code here that you haven't debugged beforehand - either as an answer or to seek help correcting.