vba

Add hyperlink into Word Content Control with VBA

纵饮孤独 提交于 2021-02-10 19:43:34
问题 I have a Word 2010 template. When used, a form is presented to the user and they are prompted to enter a string in a textbox named BugNumTextBox . Upon command, I wish to construct a URL, create a hyperlink, and insert that into the document. The desired insertion point (anchor) is a Rich Text Content Control with a tag name of "foo". For the address parameter I have attempted: 1) To specify the range of the content control 2) To specify the range of a bookmark (named BugNum) that I created

How to make Microsoft Word visible after opening an Excel file in Word VBA

风流意气都作罢 提交于 2021-02-10 19:34:08
问题 I have a VBA Word macro that opens a Word doc, then opens an Excel file, selects a cell reference and finally displays a message using Msgbox. After the Excel file has been opened I am having trouble finding the code to make Word visible so that the user can view the Msgbox message without having to using the task bar to switch from Excel to Word. I tried oWord.Visible = True but VBA gives me an error. Any hints are appreciated. See the code below: Sub Module_Test() Dim oExcel As Object Dim

How to make Microsoft Word visible after opening an Excel file in Word VBA

偶尔善良 提交于 2021-02-10 19:32:43
问题 I have a VBA Word macro that opens a Word doc, then opens an Excel file, selects a cell reference and finally displays a message using Msgbox. After the Excel file has been opened I am having trouble finding the code to make Word visible so that the user can view the Msgbox message without having to using the task bar to switch from Excel to Word. I tried oWord.Visible = True but VBA gives me an error. Any hints are appreciated. See the code below: Sub Module_Test() Dim oExcel As Object Dim

VBA Macro to run PowerShell Command

我的梦境 提交于 2021-02-10 18:49:27
问题 I am trying to create a macro, that would be able to rename all files with ".docx" extension in a folder. The PowerShell command works when used directly, but when used through the VBA code, it's not executing. Sub test() Dim retval Dim pscmd pscmd = "PowerShell -ExecutionPolicy Bypass -Command ""Get-ChildItem -Path *.docx -Recurse | Rename-Item -NewName {$_.Name.Substring(0,7) + $_.Extension }""" retval = Shell(pscmd, vbNormalFocus) Debug.Print pscmd End Sub The script is executing without

How to keep the Row Height constant when a table is pushed down on the sheet

这一生的挚爱 提交于 2021-02-10 18:48:06
问题 I have a sheet with 2 tables. Each table has a header that I want to be a height of 30 while all table rows are the standard 15. When I add a row to the top table, the bottom table gets pushed down. The header Height on the bottom table picks up the height of the new spreadsheet row. Is there a way to make the bottom table keep its header height at 30? Here is my code to add rows to the top table. Set tblAssemblies = Worksheets("Summary").ListObjects("Table1") Count = 1 Do tblAssemblies

How to keep the Row Height constant when a table is pushed down on the sheet

五迷三道 提交于 2021-02-10 18:41:51
问题 I have a sheet with 2 tables. Each table has a header that I want to be a height of 30 while all table rows are the standard 15. When I add a row to the top table, the bottom table gets pushed down. The header Height on the bottom table picks up the height of the new spreadsheet row. Is there a way to make the bottom table keep its header height at 30? Here is my code to add rows to the top table. Set tblAssemblies = Worksheets("Summary").ListObjects("Table1") Count = 1 Do tblAssemblies

Embed powershell script in VBA macro and run it from there

北慕城南 提交于 2021-02-10 18:41:34
问题 I am trying to write this neat little bit of code and am having some massive issues with the last bit of it. So the intention was to write a code that would go into all the .zip files in a folder, find a folder in each by name, go inside, find a file ending in "_nl.inp" and copy it outside the archive. While digging for ideas as far as VBA goes I could only find how to unzip the entire archive and not just pinpoint the file and pull i out. But I managed to find how to do this in powershell

Copying Data From Word Document Using Excel VBA

白昼怎懂夜的黑 提交于 2021-02-10 18:40:59
问题 I have an excel file that that has a filename of a word document. I want to use excel vba to open the word document, then search for a specific phrase, copy the characters following that phrase, and paste it back into the original excel file. I have attempted several ways to implement this design, with little success. Below is my most recent attempt. My main issue is that the program usually just stops when it hits my with statement. Why does that happen, and how do I fix things so that the

Embed powershell script in VBA macro and run it from there

房东的猫 提交于 2021-02-10 18:40:51
问题 I am trying to write this neat little bit of code and am having some massive issues with the last bit of it. So the intention was to write a code that would go into all the .zip files in a folder, find a folder in each by name, go inside, find a file ending in "_nl.inp" and copy it outside the archive. While digging for ideas as far as VBA goes I could only find how to unzip the entire archive and not just pinpoint the file and pull i out. But I managed to find how to do this in powershell

Simple Histogram in VBA?

牧云@^-^@ 提交于 2021-02-10 18:36:18
问题 I have data stored in some column (Say, Column A). The length of Column A is not fixed (depends on previous steps in the code). I need a histogram for the values in Column A, and have it in the same sheet. I need to take the values in column A, and automatically compute M Bins, then give the plot. I looked online for a "simple" code, but all codes are really fancy, with tons of details that I don't need, to the extent that I am not even able to use it. (I am a VBA beginner.) I found the