Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-23-2016, 04:28 AM
gbrew584 gbrew584 is offline worksheetfunction not working when controlling excel from word. Windows 7 64bit worksheetfunction not working when controlling excel from word. Office 2013
Novice
worksheetfunction not working when controlling excel from word.
 
Join Date: Apr 2015
Location: Ohio
Posts: 28
gbrew584 is on a distinguished road
Default

Many thanks for the reply, i thought I tried that, but I think maybe my method of testing the code may have failed. I tried to edit the code and then I would use F8 and drag the yellow arrow down to that bit of code, then I would press F5. but i think the problem is that my code was reset causing the code to loose the stored variables? Is there a way I test just one section of my code? Sorry I'm getting a little off the topic.

i tried your suggestion, but now I i am getting a script out of range error. I added xlbook.sheet(1), in front of .cell, but I don't think that is helping things. I changed sheet to sheets, but nothing happened. I'm getting the script out of range error. Do you have any suggestions for that?



Thanks again for taking the time to help me.
Reply With Quote
  #2  
Old 05-23-2016, 04:33 AM
gbrew584 gbrew584 is offline worksheetfunction not working when controlling excel from word. Windows 7 64bit worksheetfunction not working when controlling excel from word. Office 2013
Novice
worksheetfunction not working when controlling excel from word.
 
Join Date: Apr 2015
Location: Ohio
Posts: 28
gbrew584 is on a distinguished road
Default

gmayor,

thanks for the reply and the suggestion. I have added constants to my code to take care of the Excel specific commands, at least I thought that is what I they were doing. Is that not correct? Is there better or more correct way to do this?
Reply With Quote
  #3  
Old 05-23-2016, 05:15 AM
macropod's Avatar
macropod macropod is offline worksheetfunction not working when controlling excel from word. Windows 7 64bit worksheetfunction not working when controlling excel from word. Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by gbrew584 View Post
Is there a way I test just one section of my code? Sorry I'm getting a little off the topic.
That's fairly basic. Just use something like:
Code:
Sub Test()
Dim xlApp As Object, xlbook As Object, LastRow As Long
Const xlpart = 2
Const xlbyrows = 1
Const xlprevious = 2
Const xlformulas = 5
Set xlApp = CreateObject("Excel.Application")
Set xlbook = xlApp.workbooks.Add
xlbook.Sheets(1).Range("A1").PasteSpecial
With xlbook.Sheets(1)
    If xlApp.WorksheetFunction.CountA(.Cells) <> 0 Then
        LastRow = .Cells.Find(What:="*", _
                      After:=.Range("A1"), _
                      Lookat:=xlpart, _
                      LookIn:=xlformulas, _
                      SearchOrder:=xlbyrows, _
                      SearchDirection:=xlprevious, _
                      MatchCase:=False).Row
     Else
         LastRow = 1
     End If
  End With
  MsgBox LastRow
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #4  
Old 05-23-2016, 06:25 AM
gbrew584 gbrew584 is offline worksheetfunction not working when controlling excel from word. Windows 7 64bit worksheetfunction not working when controlling excel from word. Office 2013
Novice
worksheetfunction not working when controlling excel from word.
 
Join Date: Apr 2015
Location: Ohio
Posts: 28
gbrew584 is on a distinguished road
Default

Thanks, again, Paul for the suggestion. I guess I just don't know enough about vba to know the basics. Thanks for teaching me. I doubt I would know which bit of code to keep to do a test, but i appreciate the pointers. I can experiment with your advice and see how it goes.

Do you have any tips or hints as to why the code stops at
Code:
 LastRow = .Cells.Find(What:="*", _
                      After:=.Range("A1"), _
                      Lookat:=xlpart, _
                      LookIn:=xlformulas, _
                      SearchOrder:=xlbyrows, _
                      SearchDirection:=xlprevious, _
                      MatchCase:=False).Row
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Word to Excel Links Stop Working DAC8190 Word 1 10-08-2015 05:56 PM
Controlling Widows (single-word lines at the end of a paragraph) downtownbooks Word 2 12-09-2014 03:57 PM
worksheetfunction not working when controlling excel from word. Word and Excel stopped working judyn Office 9 04-23-2013 05:10 AM
Controlling search option in word suvvi Word 0 08-05-2011 06:10 AM
worksheetfunction not working when controlling excel from word. working with excel tables in MS word radman154 Word Tables 1 03-25-2011 12:04 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:52 PM.


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