Pasted Text Not Recognized When Creating A Word Document With VBA

longtallsunny

New Member
Joined
Mar 10, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I have created a spreadsheet where each column matches a [variable] in a Word document. Using VBA, I replace the [variable] in the Word document with the contents of the cell in the active row. It works beautifully EXCEPT when I copy a string of text from another document (pdf or doc). To be specific, my worksheet has several variables, two of which are [shorttitle] and [longtitle]. My Word document says "Protocol: {shorttitle]: [longtitle]" When I enter data into my Excel worksheet, I usually copy and paste from another document. When I run my macro, my Word document will say "Protocol: SHORT TITLE I ENTERED: " So there is nothing for [longtitle]. HOWEVER, if I key in the long title myself, it will show up. Furthermore, if I copy the long title from a different cell in Excel it will show up. The cell format is General, which is what every other cell is. To muddy it even further, I copy and paste the [shorttitle] from another document and have no issues. Does this make sense? Anyone have a clue how to fix this?
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

longtallsunny

New Member
Joined
Mar 10, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
****edit to above: my Word document says "Protocol: [shorttitle]: [longtitle]" I used the wrong bracket....****
 

Watch MrExcel Video

Forum statistics

Threads
1,130,042
Messages
5,639,725
Members
417,108
Latest member
Thein Than

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top