Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-03-2017, 07:31 AM
angelic.andy.1964 angelic.andy.1964 is offline wdAlignParagraphLeft and wdLineSpaceSingle declaration Windows 10 wdAlignParagraphLeft and wdLineSpaceSingle declaration Office 2016
Novice
wdAlignParagraphLeft and wdLineSpaceSingle declaration
 
Join Date: Jan 2017
Posts: 4
angelic.andy.1964 is on a distinguished road
Default wdAlignParagraphLeft and wdLineSpaceSingle declaration

Hi,

Below is a function I am attempting to write to ease my work.

Function Format_Table(spacebefore1 As Single, spaceafter1 As Single, fontsize As Single, wdLineSpaceSingle1 As Single, wdAlignParagraphLeft1 As Long, LineWidth1 As Single, TopL As Long, BottomL As Long, LeftL As Long, RightL As Long, DiagonalDownL As Long, DiagonalUpL As Long)


When I ran the code, wdLineSpaceSingle1 and wdAlignParagraphLeft1 turn up empty.
I tried with Single, Double, Integer, Long, String and all turn up empty.



Please advise how I should proceed from this point.

Thank you in advance for your time.

Regards
Andy
Reply With Quote
  #2  
Old 01-03-2017, 01:26 PM
macropod's Avatar
macropod macropod is offline wdAlignParagraphLeft and wdLineSpaceSingle declaration Windows 7 64bit wdAlignParagraphLeft and wdLineSpaceSingle declaration Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

That would be impossible to diagnose without seeing the rest of the function... Even then, the problem may or may not be with the function - it could be with how you're calling it and/or how you're interpreting whatever it returns.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 01-04-2017, 07:41 AM
angelic.andy.1964 angelic.andy.1964 is offline wdAlignParagraphLeft and wdLineSpaceSingle declaration Windows 10 wdAlignParagraphLeft and wdLineSpaceSingle declaration Office 2016
Novice
wdAlignParagraphLeft and wdLineSpaceSingle declaration
 
Join Date: Jan 2017
Posts: 4
angelic.andy.1964 is on a distinguished road
Default

Hi,

I have put in more details below.
How should I declare AlighTxt?

Sub Insert_Seven_Column()

Set myTable = ActiveDocument.Tables.Add(Range:=Selection.Range, NumRows:=1, Numcolumns:=7)
myTable.Select
Call Format_Table(12, wdAlignParagraphRight)

End Sub

Function Format_Table(fontsize As Single, AlignTxt As Long)

With Selection
.Font.Name = "Arial"
.Font.Size = fontsize
.ParagraphFormat.Alignment = AlighTxt

.MoveDown Unit:=wdLine, count:=1
.TypeParagraph
End With

End Function

Thank you in advance for your time.

Regards
Andy
Reply With Quote
  #4  
Old 01-04-2017, 12:04 PM
macropod's Avatar
macropod macropod is offline wdAlignParagraphLeft and wdLineSpaceSingle declaration Windows 7 64bit wdAlignParagraphLeft and wdLineSpaceSingle declaration Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

When I run your code (after fixing .ParagraphFormat.Alignment = AlighTxt), I get a 1-row by 7-column table formatted in 12pt Arial. Leaving coding efficiencies aside, I don't see what the problem is.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 01-06-2017, 08:53 AM
angelic.andy.1964 angelic.andy.1964 is offline wdAlignParagraphLeft and wdLineSpaceSingle declaration Windows 10 wdAlignParagraphLeft and wdLineSpaceSingle declaration Office 2016
Novice
wdAlignParagraphLeft and wdLineSpaceSingle declaration
 
Join Date: Jan 2017
Posts: 4
angelic.andy.1964 is on a distinguished road
Default

Thanks for helping running the code.

The problem that I encounter is that when I select each cell, the text are all left align, not right align as the code that I wrote intended to.

When I ran the debug (ctrl + F8) in VB editor, the alignTxt showed up "empty", but fontsize showed "12". So I know the declaration for alignTxt is wrong but I have no clue how to correct it.
Reply With Quote
  #6  
Old 01-06-2017, 01:14 PM
macropod's Avatar
macropod macropod is offline wdAlignParagraphLeft and wdLineSpaceSingle declaration Windows 7 64bit wdAlignParagraphLeft and wdLineSpaceSingle declaration Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Did you correct:
.ParagraphFormat.Alignment = AlighTxt
?

It should be:
.ParagraphFormat.Alignment = AlignTxt
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 01-06-2017, 03:06 PM
angelic.andy.1964 angelic.andy.1964 is offline wdAlignParagraphLeft and wdLineSpaceSingle declaration Windows 10 wdAlignParagraphLeft and wdLineSpaceSingle declaration Office 2016
Novice
wdAlignParagraphLeft and wdLineSpaceSingle declaration
 
Join Date: Jan 2017
Posts: 4
angelic.andy.1964 is on a distinguished road
Default

Thank you Paul for your help.

It has been resolved.

It was actually my stupid typo error.
Reply With Quote
  #8  
Old 01-06-2017, 09:27 PM
macropod's Avatar
macropod macropod is offline wdAlignParagraphLeft and wdLineSpaceSingle declaration Windows 7 64bit wdAlignParagraphLeft and wdLineSpaceSingle declaration Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Hint: In the VBA Editor, go to Tools|Options>Editor and check 'Require variable declaration'. Although it means you'll have to declare your variables (e.g. Dim myTable As Table), it also means errors of this kind will be trapped.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Occasional 'Overflow' error in constant declaration Cosmo Word VBA 2 07-19-2016 06:16 AM
wdAlignParagraphLeft and wdLineSpaceSingle declaration Variable declaration lwhistler Word VBA 2 08-26-2015 04:02 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:44 PM.


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