#1
|
|||
|
|||
chatGPT can write VBA!
Hi,
This isn't a question, but I just wanted to share my first experience with chatGPT. We are writing a VBA script that highlights all superscript number in a document. I asked chatGPT if it could write this script, and it did! If you have never heard of it, chatGPT is artificial intelligence (AI). It took some back and forth conversation with it until I got it to where I wanted. But this is changing the world. I'm attaching a PDF of my conversation with it as it arrived at the solution. I tested the script and it works great. Then, I asked it to create a toggle button. I haven't tried the toggle button steps yet. |
#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] |
|
Similar Threads | ||||
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 |
Write Test | dkub | Word VBA | 1 | 07-21-2012 09:01 PM |