word-vba

To replace a text in word document with Hyperlinks, using VBScript

a 夏天 提交于 2020-06-27 18:38:07
问题 I would like to replace a text ,say, 'hello', anywhere in a word document and replace it with Hyperlink - 'http://www.google.com'.I am using a replace function to achieve the same. I understand that the .Range() should be pointing to the text that needs to be replaced. But how. And how will I pass the hyperlink argument to the replace(). Here a sample of the defective code : Set objWord = CreateObject("Word.Application") Set objDoc = objWord.Documents.Open("C:\Test\Test_Hyperlink.docx") Set

Word VBA to refresh embedded Excel chart

旧街凉风 提交于 2020-06-18 11:53:08
问题 I have embedded charts in a Word doc. When I update the data in Excel, so that the chart in the Excel workbook updates, and then go to the Word doc, I can manually select the embedded chart, select Design > Refresh Data, and the embedded chart in Word updates to show the new data. When I try to record the Word VBA to do that, it won't let me do those actions. I've looked everywhere I can think of in Word's object browser. I see that I can identify the embedded chart like this: thisdocument

Word VBA to refresh embedded Excel chart

风流意气都作罢 提交于 2020-06-18 11:50:32
问题 I have embedded charts in a Word doc. When I update the data in Excel, so that the chart in the Excel workbook updates, and then go to the Word doc, I can manually select the embedded chart, select Design > Refresh Data, and the embedded chart in Word updates to show the new data. When I try to record the Word VBA to do that, it won't let me do those actions. I've looked everywhere I can think of in Word's object browser. I see that I can identify the embedded chart like this: thisdocument

Word VBA to refresh embedded Excel chart

北战南征 提交于 2020-06-18 11:50:07
问题 I have embedded charts in a Word doc. When I update the data in Excel, so that the chart in the Excel workbook updates, and then go to the Word doc, I can manually select the embedded chart, select Design > Refresh Data, and the embedded chart in Word updates to show the new data. When I try to record the Word VBA to do that, it won't let me do those actions. I've looked everywhere I can think of in Word's object browser. I see that I can identify the embedded chart like this: thisdocument

VBA Excel - Unable to open existing Word Document file

岁酱吖の 提交于 2020-06-18 05:32:54
问题 I have a simple macro that opens a Word Document using Excel. I made sure the Word Object Library is properly referenced but when running this macro it freezes after Documents.Open is called (based on me seeing where it fails in the debugger). I don't know if it is a OLE Automation Error but the macro freezes and I have to force close Excel. Public Const Dir = "C:/Temp/" Public Const File = "temp.docx" Public Sub OpenFile() Dim f As String: f = Dir & File Dim oWord As Object, oDoc As Object

push to git from vba on windows

喜夏-厌秋 提交于 2020-06-17 03:37:48
问题 I am developing word and excel macros, however to keep revision control and track changes I would like to use GitLab So what I have done so far is to have a code which export out all vba code to a folder on my PC(Z:/Dokumentstyring/GIT), when I run my publish sub routine: Private Sub publish() ThisDocument.save Call ExportVisualBasicCode ' Here I would like to automatically push the code to GIT Call CloseAll End Sub Then I manually go into git shell and type: git config --global user.name

How to retrieve data from Excel and add to Word

我怕爱的太早我们不能终老 提交于 2020-04-16 07:46:30
问题 I have a Word template file that retrieves data from an Excel file to populate a form. The code looks something like this: Dim myXL As Object Set myXL = Getobject("myfile.xls") myXL.Application.Visible = True myXL.Parent.Windows(1).Visible = True This code works fine in Office 2010 and 2007, but when I try it in 2013, it gives run time error 9 which is an array subscript error . When I check the Windows array it has zero elements, so error is correct. How do I achieve the same result in 2013?

How to retrieve data from Excel and add to Word

喜欢而已 提交于 2020-04-16 07:46:12
问题 I have a Word template file that retrieves data from an Excel file to populate a form. The code looks something like this: Dim myXL As Object Set myXL = Getobject("myfile.xls") myXL.Application.Visible = True myXL.Parent.Windows(1).Visible = True This code works fine in Office 2010 and 2007, but when I try it in 2013, it gives run time error 9 which is an array subscript error . When I check the Windows array it has zero elements, so error is correct. How do I achieve the same result in 2013?

VBA power operator (^) not working as expected in 64-bit VBA [duplicate]

北城余情 提交于 2020-03-02 10:09:59
问题 This question already has an answer here : Why do I need a space before the '^' operator in VBA for Excel 2013 or it will produce a compile time error “Expected list or separator” (1 answer) Closed 2 years ago . I feel foolish for asking and I'm sure there's a simple answer. I'm trying to get a power for a number as follows: Sub test() Dim number As Long number = 2^8 ' Expect to get 256 here End Sub This produces an error: 'Expected: list separator or )'. I'm surprised this doesn't work. I'm

VBA power operator (^) not working as expected in 64-bit VBA [duplicate]

你离开我真会死。 提交于 2020-03-02 10:06:32
问题 This question already has an answer here : Why do I need a space before the '^' operator in VBA for Excel 2013 or it will produce a compile time error “Expected list or separator” (1 answer) Closed 2 years ago . I feel foolish for asking and I'm sure there's a simple answer. I'm trying to get a power for a number as follows: Sub test() Dim number As Long number = 2^8 ' Expect to get 256 here End Sub This produces an error: 'Expected: list separator or )'. I'm surprised this doesn't work. I'm