Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-21-2023, 07:48 PM
BrianHoard BrianHoard is offline chatGPT can write VBA! Windows 10 chatGPT can write VBA! Office 2019
Advanced Beginner
chatGPT can write VBA!
 
Join Date: Jul 2022
Location: Haymarket, VA USA
Posts: 85
BrianHoard is on a distinguished road
Default 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.
Attached Files
File Type: pdf chatGPT.pdf (129.8 KB, 5 views)
Reply With Quote
  #2  
Old 01-22-2023, 02:04 PM
macropod's Avatar
macropod macropod is offline chatGPT can write VBA! Windows 10 chatGPT can write VBA! Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



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
chatGPT can write VBA! Write Test dkub Word VBA 1 07-21-2012 09:01 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:58 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft