How to Work With Documents in Word VBA

Поділитися
Вставка
  • Опубліковано 23 гру 2024

КОМЕНТАРІ • 35

  • @adriancelis9691
    @adriancelis9691 4 роки тому +7

    Thanks for sharing this information! There are lots of vba videos out there but not so much for Word.

    • @SigmaCoding
      @SigmaCoding  4 роки тому +2

      That was one of the reasons I started this whole Word VBA series was because of that specific reason. It's so hard to find content on it.

  • @ha094
    @ha094 3 роки тому +1

    Many thanks. You have struggled a lot to learn Word VBA. There are no good books to
    learn Word VBA. Microsoft In its wisdom has not provided detailed help on word VBA.
    I have been searching Google to learn Word VBA codes for a long time. Your video was helpful in clearing my doubts.

  • @Englishpa464
    @Englishpa464 2 роки тому

    You're super genius. I wanna learn more things about VBA for beginners.

  • @christyfive9584
    @christyfive9584 4 роки тому +3

    Thank you for this. Great video and you are quite right, Word is so under represented.

    • @SigmaCoding
      @SigmaCoding  4 роки тому +1

      It really is underrepresented; I wish more people would cover that and PowerPoint more. Even OneNote would be nice too.

  • @rushas
    @rushas 4 роки тому

    Good job, very useful.
    You've showed most essential parts

  • @pradeep8780
    @pradeep8780 3 роки тому +1

    How set all the table in word document with left alligned.. And set width in "cm"

  • @luxthill500
    @luxthill500 3 роки тому +2

    Very interesting tutorials. Would it be possible to split a document by a style (heading…) and save each part with all styles with the name of the heading ?

  • @ABSBOnline
    @ABSBOnline 5 років тому +1

    Excellent....

  • @gautamparekh9768
    @gautamparekh9768 3 роки тому

    is there any changes require for VBA code for diff versions of MS Word? Also let me if we can connect on any code forum ??
    We have application which opens template in diff MS word and office 365 but when we installed MS office 2016 or 2019 ver. It create issue.
    need someone's help ?
    I am not VBA programmer but its part of my project.

  • @eagillum
    @eagillum 4 роки тому

    I am working with content controls and need the font in my drop-down menus to be grey before being selected, and then turn black when something is selected. Can I program that through VBA? (total beginner here)

  • @stefanogattoCH
    @stefanogattoCH 3 роки тому

    Very useful! Thanks!

  • @johnmacn
    @johnmacn 2 роки тому

    Not so default. I had to search for it in templates. It did not come up in the first several pages of templates. Probably a MS hic up as they always do. As good as I am programming in VBA for Excel and Access I never ventured into these statements. It is nice to see another side to VBA.

  • @Elia1962
    @Elia1962 2 роки тому

    Is it possible to get the code of your example? Thanks

  • @ramanjha5474
    @ramanjha5474 5 років тому +2

    Can you help me to update a text at another place that i type at one place?

    • @SigmaCoding
      @SigmaCoding  5 років тому

      Can you give me an example of what you're trying to do?

    • @ramanjha5474
      @ramanjha5474 5 років тому +1

      @@SigmaCoding when i type a text under one heading part of it same should be typed under different heading as well which normally falls on different page. Which i mannualy copy and paste to another heading.

    • @SigmaCoding
      @SigmaCoding  5 років тому

      @@ramanjha5474 Gotcha, so that's a little complex, especially if it's not in the header and footer. If you know the number of ranges you want to edit beforehand, what you could do is add an event to document that would change all the ranges so that they all match. The problem is you would only want this event to be triggered if one of the ranges that are "linked" to the other ranges is modified.
      Also, it would probably make sense that this is only executed once you have finished modifying the range. In other words, don't keep updating it as I'm typing only update the ranges after I'm finished editing.

  • @Frank183847572828
    @Frank183847572828 4 роки тому

    I'm not very knowledgeable in programming but I'm trying to learn. So I've got a Word Document which is some sort of template. I made a little VBA GUI with Radio Buttons and Checkboxes. Based on the value selected, I would like to click on a button to replace bookmarked value or search for keywords within that word document template and replace these value with constant variable based on the selection choice.
    ie:
    First Name: (Textbox)
    Last Name: (Textbox)
    Diplomas: (Checkbox with choices; High School, College, University (University unlock more choices; Bachelor, Master, Doctorat)
    Date of Graduation: (Textbox under date format)
    Values are imported based on Word VBA GUI.
    GUI had a Document_Open() function to Load my GUI form so when I open the doc, I get the GUI on top.
    I make my selection and I am trying to fill chosen field in the document based on what the GUI captured...
    I'm really tumbling right now and making very slow progress but I was wondering if you could give me a hand on that.

    • @SigmaCoding
      @SigmaCoding  4 роки тому

      If I am understanding this correctly, you have a GUI that was built using VBA. That GUI has different components that display different pieces of information or allow a user to enter/choose different pieces of information. The user fills out your GUI, and you have a button that will "export" the values in the GUI to different parts of a Word Document template that you created.
      However, you're struggling with the actual "exporting" of values from the GUI to the Document, correct? If that is the case, I need to see the actual code that you're using so I can see how everything is "talking to each other". If you don't mind could you please send all the code you currently have, along with a copy of the template so I can see how it's laid out to my email coding.sigma@gmail.com?

  •  4 роки тому

    Ca you show me how to copy text using VBA on word? Like a button to copy a text rather than I select, copy and paste?

  • @jeroenroosen1052
    @jeroenroosen1052 3 роки тому +1

    You showed how you can show the statistics of a document like how many characters are there in the document. But how can this function be used on the 'front' side of the document? So how can the user of the document use this? That's not clearing to me

    • @SigmaCoding
      @SigmaCoding  3 роки тому

      Well, the statistics are available from the ribbon and some of them are displayed in the bottom. That's where the user could get them if needed.

  • @user-zb5jp4ti1d
    @user-zb5jp4ti1d 4 роки тому

    Thank you for word vba videos. Would you be able to create a tutorial on the range object as it pertains to word vba. Thanks

  • @muthuperumalkonar4874
    @muthuperumalkonar4874 3 роки тому

    Hi,
    I have 1000 pages in word document
    In that 1st page has two highlighted word in two different places
    And I want to highlight rest 999 page at exact the same location ...
    Can you please share the VBA code for that

  • @hsoh1882
    @hsoh1882 4 роки тому

    What dose it mean vba without working with document?

  • @haafizinam
    @haafizinam 4 роки тому

    Excellent video, helped me a lot. Can you please help me storing some strings in word document file using vba ? string will not be shown unless I run some code again to retrieve that string

    • @SigmaCoding
      @SigmaCoding  4 роки тому

      Like you want to store the Words in like an array?

    • @haafizinam
      @haafizinam 4 роки тому

      @@SigmaCoding Thanks for replying, my problem has been solved by viewing Microsoft docs. The currently problem I am facing is that I want to develop a website on which a user will upload a word document in "docx" format and will apply some operations (vba in the background) on the file and will download the file with the vba code applied. For such purpose, how can I use VBA in visual studio or any other web development IDE ?

  • @smutib2863
    @smutib2863 5 років тому +1

    How to code a command button to output question with selected radio button option on a SEPARATE document?
    Ex.
    How are you? (X) Good ( ) Bad -------> click Submit (command button ------> How are you? Good [separate document]

    • @SigmaCoding
      @SigmaCoding  5 років тому

      You want to modify one document based on the results of another document's radial button value? Is that correct?

    • @smutib2863
      @smutib2863 5 років тому

      @@SigmaCoding No, just open new separate document with the question and selected answer. Here's a link to the document I'm trying to create the command button for: pixeldrain.com/u/XYstXbgl
      So only the selected answers & filled textboxes would go on a separate document with their respective questions and titles and all (ex. ACO blah blah). It's basically a new document with the exact same as this document, but only with the answers.

  • @OpinionatedReviewer
    @OpinionatedReviewer 2 роки тому

    I need a Word Macro to convert selection text from this: This is a =selection in a word =document. To this: This is a s________ in a word d_______. Can anyone help me out?
    I've tried
    Sub conv_1()
    Dim Sentence As String
    Dim i As Integer
    Sentence = Selection.Text
    For i = 1 To Len(Sentence)
    If Mid(Sentence, i, 1) Like "[a-zA-Z]" Then
    Mid(Sentence, i, 1) = "_"
    End If
    Next i
    Selection.Text = Sentence
    End Sub
    but it converts all the selected words to Dash-Dash-Dash.
    I've also tried
    Sub conv_2()

    'Declare variables
    Dim intCount As Integer
    Dim intLength As Integer
    Dim strInput As String
    Dim strOutput As String
    Dim strTemp As String

    'Get the selected text
    strInput = Selection

    'If nothing is selected, exit
    If strInput = "" Then
    Exit Sub
    End If

    'Split the string into an array
    Dim arrWords
    arrWords = Split(strInput)

    'Loop through each word in the array
    For intCount = LBound(arrWords) To UBound(arrWords)

    'Get the length of the word
    intLength = Len(arrWords(intCount))

    'If the word is longer than 1 character, convert the word
    If intLength > 1 Then
    strTemp = arrWords(intCount)
    strOutput = strOutput & Left(strTemp, 1) & String(intLength - 2, "_") & _
    Right(strTemp, 1) & " "
    Else
    'If the word is 1 character, add it to the output string
    strOutput = strOutput & arrWords(intCount) & " "
    End If

    Next

    'Trim the trailing space
    strOutput = Trim(strOutput)

    'Replace the original selection with the converted text
    Selection.TypeText Text:=strOutput

    End Sub
    but it converts all words into A-Dash-A.
    I don't know how to make it so that only the words that have an equal sign next to them get turned into A-Dash-Dash. I would appreciate any help on this!