Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-29-2020, 08:42 PM
Guessed's Avatar
Guessed Guessed is offline Pass each of the rows from Excel to Word rtf in paragraphs in established order Windows 10 Pass each of the rows from Excel to Word rtf in paragraphs in established order Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,158
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Firstly when you declare variables you should explicitly define each variable's type


Dim pregunta, opA, opB, opC, opD, ans, respC, explRC, dif, ref, obj, topic, pclave, prof As String
In the above declaration, only prof is a string. All the other variables are variants. It needs to be written as
Dim pregunta as String, opA as String, opB as String

Secondly, your code creates a document and then start looping through the rows and before you move to the next row, you close the document. This means on the second pass of the loop, the document is no longer open.

Did you want one document per row or are you creating a single document containing all the row content?
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #2  
Old 06-29-2020, 11:01 PM
Visor Visor is offline Pass each of the rows from Excel to Word rtf in paragraphs in established order Windows 10 Pass each of the rows from Excel to Word rtf in paragraphs in established order Office 2013
Advanced Beginner
Pass each of the rows from Excel to Word rtf in paragraphs in established order
 
Join Date: Aug 2019
Posts: 38
Visor is on a distinguished road
Default

Truly very grateful. It is true!! I have removed 'objselection.Close savechanges: = True and now I have all the rows in one word document, which is how I need.

Now .TypeText num and .TypeText pts which is the numerical order of column A (from A8 ...) and Column J (from J8 ..) 3 points for each row

I have now declared these num and pts variables as a variant, ... but it still gives me an error

How should I declare them so that I don't get an error?
Reply With Quote
Reply

Tags
excel 2013, vba, word 2013



Similar Threads
Thread Thread Starter Forum Replies Last Post
reverse order of paragraphs, word 2010 moorea21 Word VBA 1 08-02-2018 03:47 AM
Pass each of the rows from Excel to Word rtf in paragraphs in established order automatic insert hypens until the end of the row and in empty rows between paragraphs Ivica Word 3 12-28-2015 01:31 PM
Pass each of the rows from Excel to Word rtf in paragraphs in established order Selecting values from different rows in a table and sort them in order in a single row FromF Excel 2 09-09-2014 02:30 AM
Office 2010 Excel Full pass raineraus Excel 1 09-19-2012 12:55 PM
Pass each of the rows from Excel to Word rtf in paragraphs in established order Word Merge from Excel not in same order! Coreysan Mail Merge 3 12-11-2011 04:22 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:54 AM.


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